Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/puhitaku/typedmarshal
(WIP) Smart (un)marshaller between Python object and JSON inspired by Golang's unmarshaller.
https://github.com/puhitaku/typedmarshal
Last synced: 13 days ago
JSON representation
(WIP) Smart (un)marshaller between Python object and JSON inspired by Golang's unmarshaller.
- Host: GitHub
- URL: https://github.com/puhitaku/typedmarshal
- Owner: puhitaku
- License: other
- Created: 2017-01-01T15:53:36.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-01-10T13:01:57.000Z (almost 8 years ago)
- Last Synced: 2024-09-18T04:38:10.998Z (about 2 months ago)
- Language: Python
- Homepage:
- Size: 13.7 KB
- Stars: 14
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
TypedMarshal
============Strongly typed (un)marshaller between Python object and JSON inspired by Golang's "encode/json" library.
Short example
-------------Here is a pitch for TypedMarshal.
Let there be a JSON model definition: ::
from typedmarshal import MarshalModel
class SampleModel(MarshalModel):
name: str = None
age: int = None
hobbies: List[str] = []Then unmarshal JSON: ::
js_str = '''
{
"name": "Hatsune Miku",
"age": 16,
"hobbies": ["Sing a song", "Dance to music", "Eat negi"]
}
'''js_obj = SampleModel()
js_obj.load_json(js_str)Now defined attributes are available to use: ::
>>> js_obj.name
'Hatsune Miku'>>> js_obj.hobbies
['Sing a song', 'Dance to music', 'Eat negi']Voila!
Development progress
--------------------It's still in alpha and unstable. Everything may change in future.
Contributing
------------TBD
License
-------This library is released under BSD License.