Automatic json parsing and serialing
Project description
jfjson
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
Release history Release notifications | RSS feed
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)
Built Distribution
jfjson-0.0.3-py3-none-any.whl
(5.1 kB
view hashes)