MCPcopy
hub / github.com/opendevops-cn/opendevops / json_encode

Function json_encode

scripts/tornado_source_code/tornado/escape.py:67–75  ·  view source on GitHub ↗

JSON-encodes the given Python object.

(value: Any)

Source from the content-addressed store, hash-verified

65# Please see https://github.com/tornadoweb/tornado/pull/706
66# before sending a pull request that adds **kwargs to this function.
67def json_encode(value: Any) -> str:
68 """JSON-encodes the given Python object."""
69 # JSON permits but does not require forward slashes to be escaped.
70 # This is useful when json data is emitted in a <script> tag
71 # in HTML, as it prevents </script> tags from prematurely terminating
72 # the javascript. Some json libraries do this escaping by default,
73 # although python's standard library does not, so we do it here.
74 # http://stackoverflow.com/questions/1580647/json-why-are-forward-slashes-escaped
75 return json.dumps(value).replace("</", "<\\/")
76
77
78def json_decode(value: Union[str, bytes]) -> Any:

Callers 2

finishMethod · 0.90
test_json_encodeMethod · 0.90

Calls 1

replaceMethod · 0.80

Tested by 2

finishMethod · 0.72
test_json_encodeMethod · 0.72