You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

jsondict

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsondict

Dict with json file saving / restoring support

1.2
pipPyPI
Maintainers
1

jsondict

Dict with json file saving / restoring support

  • datetime, date support
  • readable formated json
  • safely file write with file move os function
  • auto-save support
  • compression support

Install

pip install jsondict

Usage

>>> from datetime import datetime
>>> from jsondict import JsonDict
>>> db = JsonDict('var/test.json')
>>> db.clear()
>>> db.update({'b': 2, 'created': datetime(2013, 1, 27, 21, 14), 'a': 1})
>>> db.save()
>>> open(db.filename).read()
'{\n  "a": 1,\n  "b": 2,\n  "created": "2013-01-27T21:14:00Z"\n}'

Auto-save and compression

>>> import gzip
>>> db = JsonDict('var/test.json.gz', compress=True, autosave=True)
>>> db.clear()
>>> db['x'] = 'y'
>>> gzip.open(db.filename).read()
'{\n  "x": "y"\n}'

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts