cosapp.utils.json¶
Functions
|
Convert JSON serialization back. |
|
|
|
|
|
Converts an arbitrary object to a valid JSON type. |
|
|
|
|
|
Classes
|
|
|
Encode CoSApp object for JSON serialization. |
- class cosapp.utils.json.EncodingMetadata(with_types: bool = True, inputs_only: bool = False, with_drivers: bool = True, value_only: bool = False)[source]¶
Bases:
object- inputs_only: bool = False¶
- value_only: bool = False¶
- with_drivers: bool = True¶
- with_types: bool = True¶
- class cosapp.utils.json.JSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]¶
Bases:
JSONEncoderEncode CoSApp object for JSON serialization.
- default(obj)[source]¶
Implement this method in a subclass such that it returns a serializable object for
o, or calls the base implementation (to raise aTypeError).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return super().default(o)
- cosapp.utils.json.decode_cosapp_dict(document: Dict[str, Any]) Dict[str, Any][source]¶
Convert JSON serialization back.
- cosapp.utils.json.jsonify(obj: Any) None | int | float | str | bool | List[None | int | float | str | bool] | Dict[str, None | int | float | str | bool][source]¶
Converts an arbitrary object to a valid JSON type.
Raise
- Parameters:
obj (Any) – Object to convert
- Returns:
Conversion as a valid JSON type
- Return type:
JsonType
- Raises:
TypeError – If the object is not convertible
- cosapp.utils.json.object__getstate__(self, /)¶
Helper for pickle.