# paper-jsoneditor
JSON input widget for paper-admin.
[](https://pypi.org/project/paper-jsoneditor/)
[](https://github.com/dldevinc/paper-jsoneditor)
[](https://pypi.org/project/paper-jsoneditor/)
## Compatibility
- `python` >= 3.6
- `django` >= 3.1
- `paper-admin` >= 6.0
## Installation
Install the latest release with pip:
```shell
pip install paper-jsoneditor
```
Add `paper_jsoneditor` to your INSTALLED_APPS in django's `settings.py`:
```python
INSTALLED_APPS = (
# other apps
"paper_jsoneditor",
)
```
## Usage
```python
from django.db import models
from django.utils.translation import gettext_lazy as _
from paper_jsoneditor.fields import JSONField
class SampleModel(models.Model):
data = JSONField(_("JSON"))
class Meta:
verbose_name = _("Sample")
```
Result:

## Preserving JSON object keys order
By default, Django uses the `jsonb` internal type for `JSONField` (for PostgreSQL).
From the [Postgres documentation](https://www.postgresql.org/docs/15/datatype-json.html):
> <...> jsonb does not preserve white space, does not preserve the order
> of object keys, and does not keep duplicate object keys. If duplicate keys
> are specified in the input, only the last value is kept.
>
> In general, most applications should prefer to store JSON data as jsonb,
> unless there are quite specialized needs, such as legacy assumptions about
> ordering of object keys.
If you really do need to preserve the key order, use `OrderedJSONField`.
It uses the `TEXT` type to store data:
```python
from django.db import models
from django.utils.translation import gettext_lazy as _
from paper_jsoneditor.fields import OrderedJSONField
class SampleModel(models.Model):
data = OrderedJSONField(_("JSON"))
class Meta:
verbose_name = _("Sample")
```
Raw data
{
"_id": null,
"home_page": "https://github.com/dldevinc/paper-jsoneditor",
"name": "paper-jsoneditor",
"maintainer": "Mihail Mishakin",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "x896321475@gmail.com",
"keywords": "",
"author": "Mihail Mishakin",
"author_email": "x896321475@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/1a/a0/8f27e6f7f409fa3ff14394d83c19713b31c822fee791264b1fcd037f2db8/paper-jsoneditor-0.4.1.tar.gz",
"platform": "OS Independent",
"description": "# paper-jsoneditor\n\nJSON input widget for paper-admin.\n\n[](https://pypi.org/project/paper-jsoneditor/)\n[](https://github.com/dldevinc/paper-jsoneditor)\n[](https://pypi.org/project/paper-jsoneditor/)\n\n## Compatibility\n\n- `python` >= 3.6\n- `django` >= 3.1\n- `paper-admin` >= 6.0\n\n## Installation\n\nInstall the latest release with pip:\n\n```shell\npip install paper-jsoneditor\n```\n\nAdd `paper_jsoneditor` to your INSTALLED_APPS in django's `settings.py`:\n\n```python\nINSTALLED_APPS = (\n # other apps\n \"paper_jsoneditor\",\n)\n```\n\n## Usage\n\n```python\nfrom django.db import models\nfrom django.utils.translation import gettext_lazy as _\nfrom paper_jsoneditor.fields import JSONField\n\n\nclass SampleModel(models.Model):\n data = JSONField(_(\"JSON\"))\n\n class Meta:\n verbose_name = _(\"Sample\")\n```\n\nResult:\n\n\n## Preserving JSON object keys order\n\nBy default, Django uses the `jsonb` internal type for `JSONField` (for PostgreSQL).\n\nFrom the [Postgres documentation](https://www.postgresql.org/docs/15/datatype-json.html):\n\n> <...> jsonb does not preserve white space, does not preserve the order\n> of object keys, and does not keep duplicate object keys. If duplicate keys\n> are specified in the input, only the last value is kept.\n>\n> In general, most applications should prefer to store JSON data as jsonb,\n> unless there are quite specialized needs, such as legacy assumptions about\n> ordering of object keys.\n\nIf you really do need to preserve the key order, use `OrderedJSONField`.\nIt uses the `TEXT` type to store data:\n\n```python\nfrom django.db import models\nfrom django.utils.translation import gettext_lazy as _\nfrom paper_jsoneditor.fields import OrderedJSONField\n\n\nclass SampleModel(models.Model):\n data = OrderedJSONField(_(\"JSON\"))\n\n class Meta:\n verbose_name = _(\"Sample\")\n```\n",
"bugtrack_url": null,
"license": "BSD license",
"summary": "JSON input widget for paper-admin",
"version": "0.4.1",
"project_urls": {
"Homepage": "https://github.com/dldevinc/paper-jsoneditor"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f5ac07ef2322f19ccafd7b594a5b18a80a534f55c856ebf4b0644af6c3005b4f",
"md5": "35a6cc5af5d4f695b7ec50d6f257380c",
"sha256": "ab38f6f5457273b67cecadb42c4ce5efb0f2a773089ed150c0ca5338c6b740dd"
},
"downloads": -1,
"filename": "paper_jsoneditor-0.4.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "35a6cc5af5d4f695b7ec50d6f257380c",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.7",
"size": 915103,
"upload_time": "2023-06-02T08:37:07",
"upload_time_iso_8601": "2023-06-02T08:37:07.973567Z",
"url": "https://files.pythonhosted.org/packages/f5/ac/07ef2322f19ccafd7b594a5b18a80a534f55c856ebf4b0644af6c3005b4f/paper_jsoneditor-0.4.1-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1aa08f27e6f7f409fa3ff14394d83c19713b31c822fee791264b1fcd037f2db8",
"md5": "2e200dd0a901ccb7223b2ef5efbc34c2",
"sha256": "9423b4ca7825d88b898267dd0acb6541929737c13a95aaa2bc407d919f46b5b7"
},
"downloads": -1,
"filename": "paper-jsoneditor-0.4.1.tar.gz",
"has_sig": false,
"md5_digest": "2e200dd0a901ccb7223b2ef5efbc34c2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 907714,
"upload_time": "2023-06-02T08:37:09",
"upload_time_iso_8601": "2023-06-02T08:37:09.631861Z",
"url": "https://files.pythonhosted.org/packages/1a/a0/8f27e6f7f409fa3ff14394d83c19713b31c822fee791264b1fcd037f2db8/paper-jsoneditor-0.4.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-02 08:37:09",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "dldevinc",
"github_project": "paper-jsoneditor",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"tox": true,
"lcname": "paper-jsoneditor"
}