{"id":23915,"library":"jsonable","title":"JSONable","description":"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.","status":"maintenance","version":"0.3.1","language":"python","source_language":"en","source_url":"https://github.com/halfak/JSONable-data-types","tags":["json","serialization","abstract-base-class","data-types"],"install":[{"cmd":"pip install jsonable","lang":"bash","label":"Install via pip"}],"dependencies":[],"imports":[{"note":"In 0.2.1, JSONable was renamed to Type and AbstractJSONable to Base, but in 0.3.0 they were reverted. Use JSONable.","wrong":"from jsonable import Type, Base","symbol":"JSONable","correct":"from jsonable import JSONable"}],"quickstart":{"code":"from jsonable import JSONable\n\nclass Person(JSONable):\n    def __init__(self, name, age):\n        self.name = name\n        self.age = age\n\np = Person(name=\"Alice\", age=30)\njson_str = p.to_json()\nprint(json_str)\nrecovered = Person.from_json(json_str)\nprint(recovered.name, recovered.age)","lang":"python","description":"Define a class inheriting from JSONable, call to_json() to serialize and from_json() to deserialize."},"warnings":[{"fix":"Ensure downstream consumers handle missing keys when deserializing.","message":"In 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.","severity":"breaking","affected_versions":">=0.3.0"},{"fix":"Use 'from jsonable import JSONable'.","message":"The class names 'Type' and 'Base' used in v0.2.1 are deprecated. Import JSONable directly.","severity":"deprecated","affected_versions":">=0.3.0"},{"fix":"Override _to_json() and add classmethod _from_json() for custom field types.","message":"JSONable only serializes attributes that are JSON-serializable by default. Custom types require implementing _to_json() and _from_json() methods.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Ensure you inherit from JSONable and are using version 0.3.1: `from jsonable import JSONable`.","cause":"Using an older version where method name was different, or not inheriting from JSONable.","error":"AttributeError: 'Person' object has no attribute 'to_json'"},{"fix":"Call instance.to_json() which returns a JSON string.","cause":"Trying to use json.dumps directly on a JSONable instance instead of calling to_json().","error":"TypeError: Object of type 'Person' is not JSON serializable"},{"fix":"Upgrade to latest version: `pip install --upgrade jsonable`. If using v0.2.1, import Type or Base.","cause":"Version mismatch; older versions had different class names.","error":"ImportError: cannot import name 'JSONable' from 'jsonable'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}