JSON expression language for querying Python objects.
Project description
JqON
The jqon package was developed to provide a simple way to define queries in JSON format, which can later be run in Python. It can be utilized in testing automations, where expected output of a system can be submitted a predefined set of tests.
Installation
This package is fully implemented in Python. No additional compiler is necessary. After downloading the source code just run the following command from the main package folder:
$ python setup.py install
or simply by using pip
$ pip install jqson
Available Queries
Getter Queries
- attr -
{"attr": NAME}is equivalent togetattr(input_data, NAME) - item -
{"item": KEY}is equivalent toinput_data[KEY]
Path Query
- path -
Value Queries
- value -
{"value": VALUE} - variable -
{"var": [NAME, PATH]}
Functional Queries
- bool -
{"bool": null}is equivalent tobool(input_data) - len -
{"len": null}is equivalent tolen(input_data) - any -
{"any": PATH}is equivalent toany(PATH(item) for item in input_data) - all -
{"all": PATH}is equivalent toall(PATH(item) for item in input_data) - min -
{"min": PATH}is equivalent tomin(input_data, key=lambda x: PATH(x)) - max -
{"max": PATH}is equivalent tomax(input_data, key=lambda x: PATH(x)) - sum -
{"sum": PATH}is equivalent tosum(PATH(item) for item in input_data) - avg -
{"avg": PATH}is equivalent tosum(PATH(item) for item in input_data) / len(input_data)
Logical Queries
- AND -
{"AND": [PATH, ...]}is equivalent toall(PATH(input_data), ... - OR -
{"OR": [PATH, ...]}is equivalent toany(PATH(input_data), ... - NOT -
{"NOT": [PATH, ...]}is equivalent tonot any(PATH(input_data), ...
Unary Queries
- true -
{"true": PATH}is equivalent tobool(PATH(input_data)) is True - false -
{"false": PATH}is equivalent tobool(PATH(input_data)) is False - null -
{"null": PATH}is equivalent toPATH(input_data) is None - not_null -
{"not_null": PATH}is equivalent toPATH(input_data) is not None - empty -
{"empty": PATH}is equivalent toPATH(input_data) in (None, "", [], (), {}) - not_empty -
{"not_empty": PATH}}is equivalent toPATH(input_data) not in (None, "", [], (), {})
Binary Queries
- == -
{"==": [LEFT, RIGHT]}is equivalent toLEFT == RIGHT - != -
{"!=": [LEFT, RIGHT]}is equivalent toLEFT != RIGHT - > -
{">": [LEFT, RIGHT]}is equivalent toLEFT > RIGHT - < -
{"<": [LEFT, RIGHT]}is equivalent toLEFT < RIGHT - >= -
{">=": [LEFT, RIGHT]}is equivalent toLEFT >= RIGHT - <= -
{"<=": [LEFT, RIGHT]}is equivalent toLEFT <= RIGHT - in -
{"in": [LEFT, RIGHT]}is equivalent toLEFT in RIGHT - not_in -
{"not_in": [LEFT, RIGHT]}is equivalent toLEFT not in RIGHT - contains -
{"contains": [LEFT, RIGHT]}is equivalent toRIGHT in LEFT
Enumerable Queries
- take -
{"take": COUNT}is equivalent toinput_data[:COUNT] - skip -
{"skip": COUNT}is equivalent toinput_data[COUNT:] - slice -
{"slice": [START:STOP:END]}is equivalent toinput_data[START:STOP:END] - select -
{"select": PATH}is equivalent to[PATH(item) for item in input_data] - many -
{"many": PATH}is equivalent to[child for item in input_data for child in PATH(child)] - where -
{"where": PATH}is equivalent to[item for item in input_data if PATH(item)] - distinct -
{"distinct": PATH} - single -
{"single": PATH} - first -
{"first": PATH}is equivalent tonext(item for item in input_data if PATH(item)) - last -
{"last": PATH}}is equivalent tonext(item for item in reversed(input_data) if PATH(item)) - count -
{"count": PATH}is equivalent tosum(1 for item in input_data if PATH(item)
Requirements
Disclaimer
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jqon-0.1.1.tar.gz.
File metadata
- Download URL: jqon-0.1.1.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d083ffd096cd2dc3bebd8d421ba40c9f3274e7cb00d3ec980e0ff2eb4b1b1e62
|
|
| MD5 |
ebece981701b48f71a2c38780baf9291
|
|
| BLAKE2b-256 |
c02a7ed76a7c8de196a49768a0df9fab6c76d12e0335fb430425d089ed9364a5
|
File details
Details for the file jqon-0.1.1-py3-none-any.whl.
File metadata
- Download URL: jqon-0.1.1-py3-none-any.whl
- Upload date:
- Size: 21.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e78418e49415bbef737d5bfc855423edada1ebcf36b97caa982f280bbf42e67
|
|
| MD5 |
14f4885a98af246a3a5b7f66b85bffd8
|
|
| BLAKE2b-256 |
4ecc063094e87dd51d370f9729d9ece92f5d8c0049bcbacfa6f5fb98330b8faf
|