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)
Metadata
Release files for rejd 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rejd-0.0.1.tar.gz | 8.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rejd-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.6 kB
Release files / rejd-0.0.1.tar.gz
| Download URL | rejd-0.0.1.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a518941a297b6ba085bba361dc7c1a0d965b96fd39ec3fff736bdc8949091806
|
|
BLAKE2b-256 checksum How to use checksums |
e0bd824bf492969c0b4d48de45f8b8c19d45a22899ddb1a78e81a760f3c94a0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.10
|
Release files / rejd-0.0.1-py3-none-any.whl
| Download URL | rejd-0.0.1-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9036cad5ac726ea92f609cf095df90f491ae9b9c4ce91ef8c7f8199fe64b4f01
|
|
BLAKE2b-256 checksum How to use checksums |
32b2c9acd3ccd0616c9ca0828792879b7a217208308e7ca91116ba66da17557e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.10
|