Skip to main content

An abstract class that supports jsonserialization/deserialization.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsonable-0.3.1.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

jsonable-0.3.1-py2.py3-none-any.whl (11.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file jsonable-0.3.1.tar.gz.

File metadata

  • Download URL: jsonable-0.3.1.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for jsonable-0.3.1.tar.gz
Algorithm Hash digest
SHA256 137b676e8e5819fa58518678c3d1f5463cab7e8466f69b3641cbc438042eaee4
MD5 65801e0a7172c8ba959ac95c0bedbb8f
BLAKE2b-256 47f1e02151747f823dc9f13900f19d9fd61cc6aa01a5e90b3f8c2b4131bd619c

See more details on using hashes here.

File details

Details for the file jsonable-0.3.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for jsonable-0.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f7754dd27b4734e42e7f8a61c2336bc98082f715e31e29a061a95843b102dc3a
MD5 cbb3ff7b9db8ad4520d0821b2664388d
BLAKE2b-256 0e55c6bcb4ec7f93bf8f98b57d7e185cf5ee02b52473ed84d5611277f710cdcc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page