An abstract class that supports jsonserialization/deserialization.
Project Links
Meta
Author: Aaron Halfaker
Classifiers
Development Status
- 4 - Beta
Programming Language
- Python
- Python :: 3
Environment
- Other Environment
Intended Audience
- Developers
License
- OSI Approved :: MIT License
Operating System
- OS Independent
Topic
- Software Development :: Libraries :: Python Modules
This library provides and abstract base class JSONable which enables easy definition of trivially JSON-able python objects.
Installation: pip install jsonable
- Example:
>>> import jsonable >>> >>> >>> class Fruit(jsonable.Type): ... __slots__ = ('type', 'weight') ... ... def initialize(self, type, weight): ... self.type = str(type) ... self.weight = float(weight) ... >>> class Pie(jsonable.Type): ... __slots__ = ('fruit',) ... ... def initialize(self, fruit): ... self.fruit = [Fruit(f) for f in fruit] ... ... >>> pie = Pie([Fruit('apple', 10.3), Fruit('cherry', 2)]) >>> >>> doc = pie.to_json() >>> doc {'fruit': [{'weight': 10.3, 'type': 'apple'}, {'weight': 2.0, 'type': 'cherry'}]} >>> >>> pie == Pie(doc) True
Oct 01, 2015
0.3.1
Sep 22, 2015
0.3.0
Sep 04, 2015
0.2.1
Aug 24, 2015
0.2.0
Aug 15, 2014
0.1.1
Aug 05, 2014
0.1.0
Aug 02, 2014
0.0.3
Aug 01, 2014
0.0.2
Aug 01, 2014
0.0.1
Wheel compatibility matrix
Files in release
No dependencies