Skip to main content

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 to getattr(input_data, NAME)
  • item - {"item": KEY} is equivalent to input_data[KEY]

Path Query

  • path -

Value Queries

  • value - {"value": VALUE}
  • variable - {"var": [NAME, PATH]}

Functional Queries

  • bool - {"bool": null} is equivalent to bool(input_data)
  • len - {"len": null} is equivalent to len(input_data)
  • any - {"any": PATH} is equivalent to any(PATH(item) for item in input_data)
  • all - {"all": PATH} is equivalent to all(PATH(item) for item in input_data)
  • min - {"min": PATH} is equivalent to min(input_data, key=lambda x: PATH(x))
  • max - {"max": PATH} is equivalent to max(input_data, key=lambda x: PATH(x))
  • sum - {"sum": PATH} is equivalent to sum(PATH(item) for item in input_data)
  • avg - {"avg": PATH} is equivalent to sum(PATH(item) for item in input_data) / len(input_data)

Logical Queries

  • AND - {"AND": [PATH, ...]} is equivalent to all(PATH(input_data), ...
  • OR - {"OR": [PATH, ...]} is equivalent to any(PATH(input_data), ...
  • NOT - {"NOT": [PATH, ...]} is equivalent to not any(PATH(input_data), ...

Unary Queries

  • true - {"true": PATH} is equivalent to bool(PATH(input_data)) is True
  • false - {"false": PATH} is equivalent to bool(PATH(input_data)) is False
  • null - {"null": PATH} is equivalent to PATH(input_data) is None
  • not_null - {"not_null": PATH} is equivalent to PATH(input_data) is not None
  • empty - {"empty": PATH} is equivalent to PATH(input_data) in (None, "", [], (), {})
  • not_empty - {"not_empty": PATH}} is equivalent to PATH(input_data) not in (None, "", [], (), {})

Binary Queries

  • == - {"==": [LEFT, RIGHT]} is equivalent to LEFT == RIGHT
  • != - {"!=": [LEFT, RIGHT]} is equivalent to LEFT != RIGHT
  • > - {">": [LEFT, RIGHT]} is equivalent to LEFT > RIGHT
  • < - {"<": [LEFT, RIGHT]} is equivalent to LEFT < RIGHT
  • >= - {">=": [LEFT, RIGHT]} is equivalent to LEFT >= RIGHT
  • <= - {"<=": [LEFT, RIGHT]} is equivalent to LEFT <= RIGHT
  • in - {"in": [LEFT, RIGHT]} is equivalent to LEFT in RIGHT
  • not_in - {"not_in": [LEFT, RIGHT]} is equivalent to LEFT not in RIGHT
  • contains - {"contains": [LEFT, RIGHT]} is equivalent to RIGHT in LEFT

Enumerable Queries

  • take - {"take": COUNT} is equivalent to input_data[:COUNT]
  • skip - {"skip": COUNT} is equivalent to input_data[COUNT:]
  • slice - {"slice": [START:STOP:END]} is equivalent to input_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 to next(item for item in input_data if PATH(item))
  • last - {"last": PATH}} is equivalent to next(item for item in reversed(input_data) if PATH(item))
  • count - {"count": PATH} is equivalent to sum(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


Download files

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

Source Distribution

jqon-0.1.1.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

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

jqon-0.1.1-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

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

Hashes for jqon-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d083ffd096cd2dc3bebd8d421ba40c9f3274e7cb00d3ec980e0ff2eb4b1b1e62
MD5 ebece981701b48f71a2c38780baf9291
BLAKE2b-256 c02a7ed76a7c8de196a49768a0df9fab6c76d12e0335fb430425d089ed9364a5

See more details on using hashes here.

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

Hashes for jqon-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5e78418e49415bbef737d5bfc855423edada1ebcf36b97caa982f280bbf42e67
MD5 14f4885a98af246a3a5b7f66b85bffd8
BLAKE2b-256 4ecc063094e87dd51d370f9729d9ece92f5d8c0049bcbacfa6f5fb98330b8faf

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