Skip to main content

JSON Helpers

Project description

CircleCI Coverage


The jsonlib package provides utility functions for reading and writing JSON data. It supports the following features:


pip install jsonlib

Easy Read/Write


import jsonlib

data ='/foo/bar.json')


import jsonlib

jsonlib.write({'foo': 'bar'}, '/foo/bar.json')

Works Just Like The json Library


import jsonlib

with open('/foo/bar.json', 'r') as jsonfile:
    data = jsonlib.load(jsonfile)


import jsonlib

data = jsonlib.loads('{"foo": "bar"}')


import jsonlib

with open('/foo/bar.json', 'w') as jsonfile:
    jsonlib.dump({'foo': 'bar'}, jsonfile)


import jsonlib

data = {
    'apple': 'crumble',
    'banana': 'split',

# Use standard options.
text = jsonlib.dumps(data, jsonfile, indent=2, sort_keys=True)

Supports date/datetime Objects

import datetime
import jsonlib

before = {

jsonlib.write(before, '/foo/bar.json')
after ='/foo/bar.json')
assert before == after  # True

Supports dataclasses (Python 3.7+)

from dataclasses import dataclass
import jsonlib

class Fruit:
    apple: str
    banana: str

before = Fruit(apple='Fuji', banana='Lady Finger')

jsonlib.write(before, '/foo/bar.json')
after ='/foo/bar.json')
assert before == after  # True

Preserve Ordering - i.e. OrderedDict Objects

import collections
import jsonlib

before = collections.OrderedDict([('banana', 'split'), ('apple', 'crumble')])

text = jsonlib.dumps(before, indent=2)
after = jsonlib.loads(text, ordered=True)
assert before == after  # True

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for jsonio, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size jsonio-0.1.2-py2.py3-none-any.whl (6.1 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size jsonio-0.1.2.tar.gz (5.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page