API¶
structure¶
-
dataclass_structor.
structure
(value: Any, goal_type: Any) → Any¶ Returns object given a value and type signature to be coerced into.
Parameters: - value – A dict or list composed of primitive type (str, int, float) or a primitive type.
- goal_type – A type that you would like cast value into.
Usage:
>>> import datetime >>> import dataclass_structor >>> dataclass_structor.structure('2018-10-02', datetime.date) datetime.datetime(2018, 10, 2)
unstructure¶
-
dataclass_structor.
unstructure
(value: Any) → Any¶ Returns dictionary, composed of simple types, given a value of a particular type.
Parameters: value – An object that you would like to convert into a serializable object. Usage:
>>> import datetime >>> import dataclass_structor >>> dataclass_structor.unstructure(datetime.date(2018, 9, 5)) "2018-09-05"