Registry / serialization / json-logic-qubit

json-logic-qubit

JSON →
library0.9.1pypypi✓ verified 84d ago

json-logic-qubit is a Python parser that accepts JsonLogic rules and executes them. It is a port of the JavaScript json-logic-js project, designed to allow sharing rules (logic) between front-end and back-end code, and for storing logic in databases. The current version is 0.9.1. The project appears to be in maintenance mode with infrequent updates.

pip install json-logic-qubit
INSTALL
IMPORT
SIG · JSON-LOGIC-QUBIT
J
json-logic-qubit
serializationpythonv0.9.1
Install
1.6s avg
Import
28ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.9.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.029s · 17.9MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.6s · import 0.026s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

jsonLogic
from json_logic import jsonLogic
from json_logic_qubit import jsonLogic
The primary function `jsonLogic` is exposed directly from the `json_logic` sub-package, not the top-level `json_logic_qubit`.

This quickstart demonstrates how to import and use the `jsonLogic` function with both a simple comparison rule and a more complex, data-driven rule that checks nested properties.

from json_logic import jsonLogic # Simple rule: 1 == 1 result1 = jsonLogic({ "==" : [1, 1] }) print(f"Simple rule (1 == 1): {result1}") # Data-driven rule: check if 'temp' < 110 AND 'pie.filling' == 'apple' rules = { "and" : [ { "<" : [ { "var" : "temp" }, 110 ] }, { "==" : [ { "var" : "pie.filling" }, "apple" ] } ] } data = { "temp" : 100, "pie" : { "filling" : "apple" } } result2 = jsonLogic(rules, data) print(f"Complex rule (pie ready): {result2}")
Debug
Known issues
deprecatedThe json-logic-qubit library has not been updated since August 2018. While functional, it may lack compatibility with newer Python versions or not include features/bug fixes from the broader JsonLogic ecosystem. Related projects by 'QubitProducts' have been archived.
fix
Thoroughly test with your specific Python environment and consider alternative actively maintained JsonLogic implementations if long-term support or cutting-edge features are required.
affects: <=0.9.1
gotchaAn older, less maintained Python package named `json-logic` exists on PyPI. Installing it by mistake can lead to an outdated and buggy implementation of the JsonLogic specification.
fix
Always use `pip install json-logic-qubit` to ensure you get this fork, which was created to address maintenance issues of the original `json-logic` package. Verify your `from json_logic import jsonLogic` import works as expected.
affects: All versions
gotchaOlder versions of a base `json-logic` library (from which this project is forked) experienced `TypeError: 'dict_keys' object does not support indexing` with Python 3.6+. While potentially fixed in this fork, due to the project's age, unforeseen compatibility issues with modern Python versions (3.7+) may arise.
fix
Test your rules and data extensively on your target Python version. Inspect error messages for issues related to dictionary views or iteration changes in newer Python versions.
affects: Potentially Python 3.6+
gotchaSome JsonLogic implementations (in other languages) have had a known issue where the `{"var": "key"}` operator returns `None` instead of `False` when the referenced data value is literally `False`. This can break logic relying on explicit boolean `False` checks.
fix
Rigorously test rules that involve `var` operators with boolean `False` values to ensure the expected output. Consider explicit comparisons like `{"==": [{"var": "key"}, false]}` if ambiguity arises.
affects: Potentially all versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'json_logic_qubit.json_logic'
The Python package `json-logic-qubit` exposes its main functionality via the `json_logic` module, not `json_logic_qubit` directly.
fix
Change the import statement from `from json_logic_qubit import jsonLogic` (or similar) to `from json_logic import jsonLogic`.
TypeError: 'dict_keys' object does not support indexing
This error occurs in older implementations or versions of json-logic-py (the upstream project json-logic-qubit is based on) when running under Python 3.x, because `dict.keys()` returns a view object that cannot be indexed directly, unlike in Python 2.
fix
Ensure you are using `json-logic-qubit` version 0.9.1. This version should include Python 3 compatibility fixes for how dictionary keys are accessed.
ValueError: Invalid JsonLogic rule (or similar error message indicating an unknown/malformed operator)
The provided JsonLogic rule does not conform to the expected structure (e.g., contains multiple keys in an operator object, or the operator is not a valid string) or attempts to use an operator that is not implemented by `json-logic-qubit`.
fix
Verify that your JsonLogic rule strictly adheres to the JsonLogic specification (e.g., each rule is a dictionary with a single operator key and an array of arguments) and only uses operators supported by the `json-logic-qubit` library.
Upgrade
Version history
0.9.1latest on PyPI · released Aug 15, 2018
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
12
Resources
json-logic-qubit — pip install json-logic-qubit · libregistry