Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

https://circleci.com/gh/rpkilby/jsonfield2.svg?style=shield https://codecov.io/gh/rpkilby/jsonfield2/branch/master/graph/badge.svg https://img.shields.io/pypi/v/jsonfield2.svg https://img.shields.io/pypi/l/jsonfield2.svg

ARCHIVE NOTICE: This package has been deprecated and merged back into jsonfield.


jsonfield2 is a reusable model field that allows you to store validated JSON, automatically handling serialization to and from the database. To use, add jsonfield.JSONField to one of your models.

Note: django.contrib.postgres now supports PostgreSQL’s jsonb type, which includes extended querying capabilities. If you’re an end user of PostgreSQL and want full-featured JSON support, then it is recommended that you use the built-in JSONField. However, jsonfield2 is still useful when your app needs to be database-agnostic, or when the built-in JSONField’s extended querying is not being leveraged. e.g., a configuration field.

Requirements

jsonfield2 aims to support all current versions of Django, however the explicity tested versions are:

  • Python: 3.6, 3.7, 3.8

  • Django: 2.2, 3.0

Installation

pip install jsonfield2

Usage

from django.db import models
from jsonfield import JSONField

class MyModel(models.Model):
    json = JSONField()

Advanced Usage

By default python deserializes json into dict objects. This behavior differs from the standard json behavior because python dicts do not have ordered keys. To overcome this limitation and keep the sort order of OrderedDict keys the deserialisation can be adjusted on model initialisation:

import collections

class MyModel(models.Model):
    json = JSONField(load_kwargs={'object_pairs_hook': collections.OrderedDict})

Other Fields

jsonfield.JSONCharField

Subclasses models.CharField instead of models.TextField.

Running the tests

The test suite requires tox and tox-venv.

$ pip install tox tox-venv

To test against all supported versions of Django, install and run tox:

$ tox

Or, to test just one version (for example Django 2.0 on Python 3.6):

$ tox -e py36-django20

Release Process

  • Update changelog

  • Update package version in setup.py

  • Check supported versions in setup.py and readme

  • Create git tag for version

  • Upload release to PyPI test server

  • Upload release to official PyPI server

$ pip install -U pip setuptools wheel twine
$ rm -rf dist/ build/
$ python setup.py sdist bdist_wheel
$ twine upload -r test dist/*
$ twine upload dist/*

Changes

Take a look at the changelog.

Metadata

Release files for jsonfield2 4.0.0.post0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jsonfield2 4.0.0.post0
File Size Uploaded
jsonfield2-4.0.0.post0.tar.gz 12.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jsonfield2 4.0.0.post0
File Interpreter ABI Platform
jsonfield2-4.0.0.post0-py3-none-any.whl Python 3 none any Details

Total release size: 20.1 kB

Release files / jsonfield2-4.0.0.post0.tar.gz

Download URL jsonfield2-4.0.0.post0.tar.gz
Size 12.6 kB
Tags Source
SHA-256 checksum
How to use checksums
cbce2d7c52563550cd2048fcf3a57631019d3547f5ed142f42141d1d2dc53283
BLAKE2b-256 checksum
How to use checksums
ea7e9b093453c62a9599eef02274e12eb9d327519812288cad283494c4035ec1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

Release files / jsonfield2-4.0.0.post0-py3-none-any.whl

Download URL jsonfield2-4.0.0.post0-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bab284d3fc721067d5f3107a0adc87ee772e9b09cac5eca042fad6311c4842bd
BLAKE2b-256 checksum
How to use checksums
62ca4ad4bcd8d728721ac307adbaf9cb7371424773f8affcb425e3edd73e504c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page