Registry / serialization / jsonable

jsonable

JSON →
library0.3.1pypypi✓ verified 84d ago

A Python library providing an abstract base class for JSON serialization/deserialization. Current version: 0.3.1. Release cadence appears sparse; last release in 2015.

pip install jsonable
INSTALL
IMPORT
SIG · JSONABLE
J
jsonable
serializationpythonv0.3.1
Install
1.5s avg
Import
28ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.030s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.026s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

JSONable
from jsonable import JSONable
from jsonable import Type, Base
In 0.2.1, JSONable was renamed to Type and AbstractJSONable to Base, but in 0.3.0 they were reverted. Use JSONable.

Define a class inheriting from JSONable, call to_json() to serialize and from_json() to deserialize.

from jsonable import JSONable class Person(JSONable): def __init__(self, name, age): self.name = name self.age = age p = Person(name="Alice", age=30) json_str = p.to_json() print(json_str) recovered = Person.from_json(json_str) print(recovered.name, recovered.age)
Debug
Known issues
breakingIn v0.3.0, fields with None values or empty dicts are omitted from serialized JSON. This can break code expecting all fields to be present.
fix
Ensure downstream consumers handle missing keys when deserializing.
affects: >=0.3.0
deprecatedThe class names 'Type' and 'Base' used in v0.2.1 are deprecated. Import JSONable directly.
fix
Use 'from jsonable import JSONable'.
affects: >=0.3.0
gotchaJSONable only serializes attributes that are JSON-serializable by default. Custom types require implementing _to_json() and _from_json() methods.
fix
Override _to_json() and add classmethod _from_json() for custom field types.
affects: all
Errors
Common errors & fixes
AttributeError: 'Person' object has no attribute 'to_json'
Using an older version where method name was different, or not inheriting from JSONable.
fix
Ensure you inherit from JSONable and are using version 0.3.1: `from jsonable import JSONable`.
TypeError: Object of type 'Person' is not JSON serializable
Trying to use json.dumps directly on a JSONable instance instead of calling to_json().
fix
Call instance.to_json() which returns a JSON string.
ImportError: cannot import name 'JSONable' from 'jsonable'
Version mismatch; older versions had different class names.
fix
Upgrade to latest version: `pip install --upgrade jsonable`. If using v0.2.1, import Type or Base.
Upgrade
Version history
0.3.1latest on PyPI · released Oct 1, 2015
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
jsonable — pip install jsonable · libregistry