3 ms·
Recently I had a similar wrote a library that creates (and dumps) your typed NamedTuples, datetimes and similar objects from simple JSON, using type annotations
by vog 9y ago
Recently I had a similar wrote a library that creates (and dumps) your typed NamedTuples, datetimes and similar objects from simple JSON, using type annotations:
"JSON support for named tuples, datetime and other objects, preventing ambiguity via type annotations"
https://github.com/m-click/jsontyping https://github.com/m-click/jsontyping
If you are interested, please have a look at the first unit tests to see how it works:
https://github.com/m-click/jsontyping/blob/master/tests/test_jsontyping.py https://github.com/m-click/jsontyping/blob/master/tests/test...
Note that the tests currently use the "ugly" NamedTuple syntax to be compatible with Python 3.5 and 2.7.