Skip to main content

Automatic json parsing and serialing

Project description

jfjson

Build

Just fucking json!

Converts json to python objects using type annotations.

@dataclass
class Record:
    name: str
    pos: int
    age: float

jfjson.loads('[{"name": "you", "pos": 42, "age": 5.2}]', List[Record])
# [Record(name='you', pos=42, age=5.2)]

It also does data validation and type checking

jfjson.loads('["a", null, 12]', List[Optional[str]])
# jfjson.core.JsonConversionError: Found <class 'int'>, but was expecting typing.Optional[str]: at location .[2]

Also knows how to write any class that has a __dict__ attribute or _asdict() function.

@dataclass
class Record:
    name: str
    pos: int
    age: float

jfjson.dumps([Record(name='you', pos=42, age=5.2)])
# '[{"name": "you", "pos": 42, "age": 5.2}]'

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

jfjson-0.0.3.tar.gz (6.0 kB view hashes)

Uploaded Source

Built Distribution

jfjson-0.0.3-py3-none-any.whl (5.1 kB view hashes)

Uploaded Python 3

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