pg.to_json#
Accessible via pg.to_json
, pg.symbolic.to_json
.
- to_json(value, **kwargs)[source]#
Serializes a (maybe) symbolic value into a plain Python object.
Example:
@pg.members([ ('x', pg.typing.Any()) ]) class A(pg.Object): pass a1 = A(1) json = a1.to_json() a2 = pg.from_json(json) assert pg.eq(a1, a2)
- Return type:
- Parameters:
value –
value to serialize. Applicable value types are:
Builtin python types: None, bool, int, float, string;
JSONConvertible types;
List types;
Tuple types;
Dict types.
**kwargs – Keyword arguments to pass to value.to_json if value is JSONConvertible.
- Returns:
JSON value.