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:
>>> from jsonable import JSONable
>>>
>>>
>>> class Fruit(JSONable):
...     __slots__ = ('type', 'weight')
...
...     def initialize(self, type, weight):
...         self.type   = str(type)
...         self.weight = float(weight)
...
>>> class Pie(JSONable):
...     __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 Distributions

jsonable-0.1.1.zip (9.6 kB view details)

Uploaded Source

jsonable-0.1.1.tar.gz (5.2 kB view details)

Uploaded Source

File details

Details for the file jsonable-0.1.1.zip.

File metadata

  • Download URL: jsonable-0.1.1.zip
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for jsonable-0.1.1.zip
Algorithm Hash digest
SHA256 d938007ca51864d7ee06cacb95e47d1d505a3c4f884743c9beeabb5ff67b98ed
MD5 d32c0d1da74c6da008f192706698b010
BLAKE2b-256 1583d82fe7a602350093e37297bd47bb5704f2b261a09be856886e794348bc44

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for jsonable-0.1.1.tar.gz
Algorithm Hash digest
SHA256 763e7642956573a5a5bf83ba708da80942fab6101ee0a2e228b91e791f146768
MD5 51a66c8651ad32b1bcd4473059929e97
BLAKE2b-256 fc0ed588c64f244d29fb8768ca547f26047dbfdac6d8bd3c1dec13526a452204

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