Skip to main content

ReJD (Representation JSON Data) - Python library that change your "JSON like" data representation.

Project description

ReJD

ReJD (Representation JSON Data) - Python library that changes your "JSON-like" data representation.

The small library will help you pull data from an input object using JSONPath and generate new objects according to a schema.

JSONPath is like XPath (XML) for JSON. To learn the syntax, read the documentation for the original article.

Installation

pip install rejd

Or you can install it from GitHub:

pip install -e git+https://github.com/rejd-tools/rejd-python.git

Usage example

schema = {
    "source": "$",  # root data (initial_data)
    "type": "object",
    "properties": {  # fields schema for the new object
        "field1": {
            "source": "@.field1 * 2",  # JSONPath
            "type": "float"
        },
        "field2": {
            "source": "@.array",
            "type": "array",
            "items": {
                "source": "@.number"
            }
        }
    }
}

data = {
    "field1": 1.5,
    "array": [
        {"number": 1},
        {"number": 2}
    ]
}

assert transform(schema, data) == {
    "field1": 3.0,
    "field2": [1, 2]
}

Testing

Just run pytest to run unit tests.

Or you can use pre-commit to check and fix any issues: pre-commit run --all

License

Apache License 2.0 (See LICENSE)

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

rejd-0.0.1.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

rejd-0.0.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file rejd-0.0.1.tar.gz.

File metadata

  • Download URL: rejd-0.0.1.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.10

File hashes

Hashes for rejd-0.0.1.tar.gz
Algorithm Hash digest
SHA256 a518941a297b6ba085bba361dc7c1a0d965b96fd39ec3fff736bdc8949091806
MD5 7e7158dcdbe8fc78dd258f55fe01a600
BLAKE2b-256 e0bd824bf492969c0b4d48de45f8b8c19d45a22899ddb1a78e81a760f3c94a0b

See more details on using hashes here.

File details

Details for the file rejd-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: rejd-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.10

File hashes

Hashes for rejd-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9036cad5ac726ea92f609cf095df90f491ae9b9c4ce91ef8c7f8199fe64b4f01
MD5 08d892618fb93a454e291492b5338aa5
BLAKE2b-256 32b2c9acd3ccd0616c9ca0828792879b7a217208308e7ca91116ba66da17557e

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