Skip to main content

JSON with datetime support

Project description

Sick of rewriting the same JSON datetime handling code for each project? jsondate is a drop-in replacement for Python’s standard json library that adds sensible handling of datetime and date objects.

jsondate uses ISO8601 for encoding datetime objects and the date-specific part of ISO6801 for encoding date objects.

It supports Python 2 and 3, and creates timezone-aware dates when able.

XXX Update this after it works

Example:

import datetime
import jsondate3 as json

>>> data = json.dumps(dict(created_at=datetime.datetime(2012, 10, 31)))
'{"created_at": "2012-10-31T00:00:00Z"}'

>>> json.loads(data)
{u'created_at': datetime.datetime(2012, 10, 31, 0, 0)}

>>> date = json.dumps(dict(date=datetime.date(2012, 10, 31)))
'{"date": "2012-10-31"}'

>>> json.loads(data)
{u'created_at': datetime.date(2012, 10, 31)}

Testing

Run them with:

python -m unittest tests.test_jsondate

Deployment

If you wish to create a new version manually, the process is:

  1. Update version info in setup.py

  2. Install the requirements in requirements_dev.txt

  3. Set up a config file at ~/.pypirc

  4. Generate a universal distribution that worksin py2 and py3 (see setup.cfg)

    rm -r dist &&  python setup.py sdist bdist_wheel
  5. Upload the distributions

    twine upload dist/* -r pypi (or pypitest)

Project details


Download files

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

Source Distribution

jsondate3-aware-0.1.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

jsondate3_aware-0.1.1-py2.py3-none-any.whl (4.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file jsondate3-aware-0.1.1.tar.gz.

File metadata

  • Download URL: jsondate3-aware-0.1.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.1.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/2.7.18rc1

File hashes

Hashes for jsondate3-aware-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f07a52ba63906bce0ee2d245e0f5923c2049e99b85d7e66d1f8c8155056c715b
MD5 02f8cf81fe52bb6da9e265c620206958
BLAKE2b-256 18556d9fa89b850f2d659989c7b7a8b00b97decc5b4e04d4374e63da0be1762e

See more details on using hashes here.

File details

Details for the file jsondate3_aware-0.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: jsondate3_aware-0.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.1.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/2.7.18rc1

File hashes

Hashes for jsondate3_aware-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f202c6651bde08d54d3585edf79d953eb65214343097d50ec64589af692050de
MD5 d0a6af85816993a3302cf48df0160177
BLAKE2b-256 c7a595e9f3a403ed0339804051958115fe842ac07723bd2e0675f1da3bcbc36d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page