python-jsonlogic is an extensible and sane implementation of JsonLogic, making use of the JSON Schema specification.
Motivation
While the JsonLogic format can be great to serialize logic, it lacks a formal specification and some aspects are unclear/unspecified:
operators arguments can take any value. For instance, comparison operators are said to work with “numeric” values, however the JavaScript playground doesn’t validate inputs. It is also convenient to allow such comparison operators for date and datetime objects as well.
Operators accessing data use a dot-like notation, which is ambiguous when dealing with keys such as my.key.
Operators such as map provides their own data scope, making it impossible to access higher-level data inside the operator expression.
For these reasons, python-jsonlogic provides a way to typecheck your JSON Logic expressions at “compile” time, before applying input data to them.
Installation
From PyPI:
pip install python-jsonlogic
The library can be imported from the jsonlogic module.
Usage
# 1. Create or use an already existing operator registry:
from jsonlogic.operators import operator_registry
# 2. Parse the JSON Logic expression:
from jsonlogic import JSONLogicExpression
expr = JSONLogicExpression.from_json({"map": [
[1, 2],
{"*": [{"var": ""}, {"var": "/my_int@1"}]},
]})
# 3. Create an operator tree:
root_op = expr.as_operator_tree(operator_registry)
# 4. Typecheck the expression:
from jsonlogic.typechecking import typecheck
typ, diagnostics = typecheck(
root_op,
data_schema={
"type": "object",
"properties": {
"my_int": {"type": "integer"}
},
}
)
print(typ)
#> ArrayType(IntegerType())
# 5. Evaluate with data:
from jsonlogic.evaluation import evaluate
value = evaluate(
root_op,
data={"my_int": 2},
data_schema=None,
)
print(value)
#> [2, 4]
Metadata
Release files for python-jsonlogic 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| python_jsonlogic-0.2.0.tar.gz | 107.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| python_jsonlogic-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 133.7 kB
Release files / python_jsonlogic-0.2.0.tar.gz
| Download URL | python_jsonlogic-0.2.0.tar.gz |
|---|---|
| Size | 107.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3a8eec20f794de789fc6714dedb159c72aff5b93fdee1e134c40b5393a0220ab
|
|
BLAKE2b-256 checksum How to use checksums |
624b4fab8a93d0c58ed4a0edd4a29c97c341033c34fa0a7d96fa0174ee066873
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.
Transparency logRelease files / python_jsonlogic-0.2.0-py3-none-any.whl
| Download URL | python_jsonlogic-0.2.0-py3-none-any.whl |
|---|---|
| Size | 26.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
21abf7b68d3c84d47f14fcb90241b5df2a3a9220a604613dd49c320d34043734
|
|
BLAKE2b-256 checksum How to use checksums |
056dd7dabd773f4d1a0b9872ea49025b2e0955c719b10f4fd6e9e62756771411
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.
Transparency log