MCPcopy Create free account
hub / github.com/piccolo-orm/piccolo / dump_json

Function dump_json

piccolo/utils/encoding.py:15–29  ·  view source on GitHub ↗
(data: Any, pretty: bool = False)

Source from the content-addressed store, hash-verified

13
14
15def dump_json(data: Any, pretty: bool = False) -> str:
16 if ORJSON:
17 orjson_params: dict[str, Any] = {"default": str}
18 if pretty:
19 orjson_params["option"] = (
20 orjson.OPT_INDENT_2 | orjson.OPT_APPEND_NEWLINE # type: ignore
21 )
22 return orjson.dumps(data, **orjson_params).decode( # type: ignore
23 "utf8"
24 )
25 else:
26 params: dict[str, Any] = {"default": str}
27 if pretty:
28 params["indent"] = 2
29 return json.dumps(data, **params) # type: ignore
30
31
32class JSONDict(dict):

Callers 6

convert_to_sql_valueFunction · 0.90
convert_array_inFunction · 0.90
clean_valueMethod · 0.90
runMethod · 0.90
__init__Method · 0.90
test_dump_loadMethod · 0.90

Calls

no outgoing calls

Tested by 1

test_dump_loadMethod · 0.72