jsonio
The jsonio package provides utility functions for reading and writing JSON data. It supports the following features:
- Easy Read/Write
- Works Just Like The
jsonLibrary - Supports
datetime/dateObjects - Supports
dataclasses(Python 3.7+) - Preserve Ordering
Installation
pip install jsonio
Easy Read/Write
Read
import jsonio
data = jsonio.read('/foo/bar.json')
Write
import jsonio
jsonio.write({'foo': 'bar'}, '/foo/bar.json')
Works Just Like The json Library
Load
import jsonio
with open('/foo/bar.json', 'r') as jsonfile:
data = jsonio.load(jsonfile)
Loads
import jsonio
data = jsonio.loads('{"foo": "bar"}')
Dump
import jsonio
with open('/foo/bar.json', 'w') as jsonfile:
jsonio.dump({'foo': 'bar'}, jsonfile)
Dumps
import jsonio
data = {
'apple': 'crumble',
'banana': 'split',
}
# Use standard options.
text = jsonio.dumps(data, jsonfile, indent=2, sort_keys=True)
Supports date/datetime Objects
import datetime
import jsonio
before = {
'date': datetime.date.today(),
'timestamp': datetime.datetime.now(),
}
data = jsonio.dumps(before)
after = jsonio.loads(data)
assert before == after # True
Supports dataclasses (Python 3.7+)
from dataclasses import dataclass
import jsonio
@dataclass
class Fruit:
apple: str
banana: str
before = Fruit(apple='Fuji', banana='Lady Finger')
data = jsonio.dumps(before)
after = jsonio.loads(data)
assert before == after # True
Preserve Ordering - i.e. OrderedDict Objects
import collections
import jsonio
before = collections.OrderedDict([('banana', 'split'), ('apple', 'crumble')])
text = jsonio.dumps(before, indent=2)
after = jsonio.loads(text, ordered=True)
assert before == after # True
Release files for jsonio 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jsonio-0.1.4.tar.gz | 5.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jsonio-0.1.4-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 11.2 kB
Release files / jsonio-0.1.4.tar.gz
| Download URL | jsonio-0.1.4.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b3aaacb6162089af963db526a3cf2bb3905fb155aa06fbc2d3c7ce171fee8b71
|
|
BLAKE2b-256 checksum How to use checksums |
ba211003b5167f802c79a1834998f9591a1fcfe9bc751a934613053aaf1cb0d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15
|
Release files / jsonio-0.1.4-py2.py3-none-any.whl
| Download URL | jsonio-0.1.4-py2.py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
6b5d1611243a795f8de4ddda746f52cf09758d53c64b4e55a3a8ab1c8e40de08
|
|
BLAKE2b-256 checksum How to use checksums |
a85cbf3ca5706d4e7e7c86c2031fc771eba093c273f936ea9f6ee545e0f8ad5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15
|