neural_compressor.ux.utils.json_serializer
¶
JsonSerializer module.
Module Contents¶
Classes¶
Dict serializable class. |
- class neural_compressor.ux.utils.json_serializer.JsonSerializer¶
Dict serializable class.
- serialize(serialization_type: str = 'default') Dict[str, Any] | List[Dict[str, Any]] ¶
Serialize class to dict.
- Parameters:
serialization_type (str, optional) – serialization type, defaults to “default”
- Returns:
serialized class
- Return type:
Union[dict, List[dict]]
- static serialize_item(value: Any, serialization_type: str = 'default') Any ¶
Serialize objects that don’t support json dump.
i.e datetime object can’t be serialized to JSON format and throw an TypeError exception TypeError: datetime.datetime(2016, 4, 8, 11, 22, 3, 84913) is not JSON serializable To handle that override method serialize_item to convert object
>>> serialize_item(datetime) "2016-04-08T11:22:03.084913"
For all other cases it should return serializable object i.e. str, int float
- Parameters:
value – Any type
serialization_type – serialization type
- Returns:
Value that can be handled by json.dump