Skip to main content

Translates Django ORM query system to json objects

Project description

PyPI - Python Version PyPI

JSON Enhanced

JSON Enhanced implements fast and pythonic queries and mutations for JSON objects.

Installation

You can install json-enhanced with pip:

pip install json-enhanced

Quickstart

import jsonutils as js
from datetime import datetime

# We create a new JSONObject either directly or from a local file/URL:
json_data = js.JSONObject(
    {
        "data": [
            {
                "name": "Dan",
                "birthday": "1991-01-02 09:00:00",
                "publications": 15
            },
            {
                "name": "Mar",
                "birthday": "1991-03-02 12:30:00",
                "publications": 13
            },
            {
                "name": "Carl",
                "birthday": "1950-06-02 16:00:00",
                "publications": 36
            },
            {
                "name": "Vic",
                "birthday": "1986-07-02 16:00:00",
                "publications": None
            },
        ]
    }
)

# Now we can navegate through this object by attribute accesion:
json_data.data._1.name
# 'Mar'

# Or we can make queries. The syntax is very similar to Django's querysets:
result = json_data.query(birthday__lt=datetime(1985,1,1))

result
# <QuerySet ['1950-06-02 16:00:00']>

result.first().parent
# {'name': 'Carl', 'birthday': '1950-06-02 16:00:00', 'publications': 36}

# We can also retrieve the path of a node:
result.first().jsonpath
# data/2/

Documentation

Detailed documentation is available at json-enhanced.readthedocs.io.

Contributing

Contributions are welcome! Please take a look at our contributors guide.

Code of Conduct

Please read CODE_OF_CONDUCT.md for details on our code of conduct.

License

This project is licensed under the GPL-3.0 License. For details, please read our LICENSE FILE.

Project details


Release history Release notifications | RSS feed

This version

0.2.4

Download files

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

Source Distribution

json-enhanced-0.2.4.tar.gz (55.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

json_enhanced-0.2.4-py3-none-any.whl (59.7 kB view details)

Uploaded Python 3

File details

Details for the file json-enhanced-0.2.4.tar.gz.

File metadata

  • Download URL: json-enhanced-0.2.4.tar.gz
  • Upload date:
  • Size: 55.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.7

File hashes

Hashes for json-enhanced-0.2.4.tar.gz
Algorithm Hash digest
SHA256 5da9ab2d9d43f627f31755467da483aac9481ada1c559cbfbb0f7bde516a9ca1
MD5 7e71e511cdf0f3c2d4f5fe7915caec1a
BLAKE2b-256 62d32cb7a59c27e72c5ae5461a16260ec0624246b4a83ee6388a87127d5f26b6

See more details on using hashes here.

File details

Details for the file json_enhanced-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: json_enhanced-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 59.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.7

File hashes

Hashes for json_enhanced-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 47b6a80cf48a00d6ce2cdd2a5259d28fce70f7c117e9edca58716fa3ba5dddd6
MD5 ea58a59c0e5c9b21988e83c147e94458
BLAKE2b-256 05261b7d3eec37aafb1abe470a518f87bd7a607c470b1833eaf58d5d8d368a26

See more details on using hashes here.

Supported by

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