MCPcopy
hub / github.com/pallets/flask / dumps

Method dumps

src/flask/json/provider.py:166–179  ·  view source on GitHub ↗

Serialize data as JSON to a string. Keyword arguments are passed to :func:`json.dumps`. Sets some parameter defaults from the :attr:`default`, :attr:`ensure_ascii`, and :attr:`sort_keys` attributes. :param obj: The data to serialize. :param kwargs: Passed to

(self, obj: t.Any, **kwargs: t.Any)

Source from the content-addressed store, hash-verified

164 """The mimetype set in :meth:`response`."""
165
166 def dumps(self, obj: t.Any, **kwargs: t.Any) -> str:
167 """Serialize data as JSON to a string.
168
169 Keyword arguments are passed to :func:`json.dumps`. Sets some
170 parameter defaults from the :attr:`default`,
171 :attr:`ensure_ascii`, and :attr:`sort_keys` attributes.
172
173 :param obj: The data to serialize.
174 :param kwargs: Passed to :func:`json.dumps`.
175 """
176 kwargs.setdefault("default", self.default)
177 kwargs.setdefault("ensure_ascii", self.ensure_ascii)
178 kwargs.setdefault("sort_keys", self.sort_keys)
179 return json.dumps(obj, **kwargs)
180
181 def loads(self, s: str | bytes, **kwargs: t.Any) -> t.Any:
182 """Deserialize data as JSON from a string or bytes.

Callers 1

responseMethod · 0.95

Calls 2

setdefaultMethod · 0.80
dumpsMethod · 0.45

Tested by

no test coverage detected