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.1.tar.gz
(5.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jfjson-0.0.1.tar.gz.
File metadata
- Download URL: jfjson-0.0.1.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93c7fbaa487e65331af1a9ec11e864c8e175649b88e912954de11a0dd7030ce0
|
|
| MD5 |
64749fb91f51f8141adbe7823ccd02f7
|
|
| BLAKE2b-256 |
7c774b7abff102dd405f8b84f1fae09e1190556c01f75999c59860e5571a2297
|
File details
Details for the file jfjson-0.0.1-py3-none-any.whl.
File metadata
- Download URL: jfjson-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2119bc0a12668d070381ecd832614a781c42c395e58cc51a8a6402985df32bcb
|
|
| MD5 |
08131f68da567d778db9df044df06b24
|
|
| BLAKE2b-256 |
27803fc2836ae56b904eccc04e3eeb910d265904298fd33dc1e4e2fa34c28998
|