pg.object_utils.to_json

Accessible via pg.object_utils.to_json.

to_json(value, *, force_dict=False, **kwargs)[source]

Serializes a (maybe) JSONConvertible value into a plain Python object.

Return type:

Any

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.

  • force_dict – If True, “_type” keys will be renamed to “type_name”. As a result, JSONConvertible objects will be returned as dict.

  • **kwargs – Keyword arguments to pass to value.to_json if value is JSONConvertible.

Returns:

JSON value.