{"id":6689,"library":"json-logic-qubit","title":"JSON Logic Qubit Python Parser","description":"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.","status":"maintenance","version":"0.9.1","language":"python","source_language":"en","source_url":"https://github.com/qubitproducts/json-logic-py","tags":["json","logic","rules","dsl","expression-language","business-rules"],"install":[{"cmd":"pip install json-logic-qubit","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The primary function `jsonLogic` is exposed directly from the `json_logic` sub-package, not the top-level `json_logic_qubit`.","wrong":"from json_logic_qubit import jsonLogic","symbol":"jsonLogic","correct":"from json_logic import jsonLogic"}],"quickstart":{"code":"from json_logic import jsonLogic\n\n# Simple rule: 1 == 1\nresult1 = jsonLogic({ \"==\" : [1, 1] })\nprint(f\"Simple rule (1 == 1): {result1}\")\n\n# Data-driven rule: check if 'temp' < 110 AND 'pie.filling' == 'apple'\nrules = {\n    \"and\" : [\n        { \"<\" : [ { \"var\" : \"temp\" }, 110 ] },\n        { \"==\" : [ { \"var\" : \"pie.filling\" }, \"apple\" ] }\n    ]\n}\ndata = { \"temp\" : 100, \"pie\" : { \"filling\" : \"apple\" } }\n\nresult2 = jsonLogic(rules, data)\nprint(f\"Complex rule (pie ready): {result2}\")","lang":"python","description":"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."},"warnings":[{"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.","message":"The 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.","severity":"deprecated","affected_versions":"<=0.9.1"},{"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.","message":"An 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Older 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.","severity":"gotcha","affected_versions":"Potentially Python 3.6+"},{"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.","message":"Some 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.","severity":"gotcha","affected_versions":"Potentially all versions"}],"env_vars":null,"search_vec":"'0.9.1':58 'accept':15 'allow':35 'appear':61 'back':45 'back-end':44 'busi':78 'business-rul':77 'code':47 'current':55 'databas':53 'design':33 'dsl':73 'end':42,46 'execut':19 'express':75 'expression-languag':74 'front':41 'front-end':40 'infrequ':68 'javascript':27 'js':31 'json':1,7,29,70 'json-logic-j':28 'json-logic-qubit':6 'jsonlog':16 'languag':76 'logic':2,8,30,38,51,71 'mainten':65 'mode':66 'parser':5,13 'port':24 'project':32,60 'python':4,12 'qubit':3,9 'rule':17,37,72,79 'share':36 'store':50 'updat':69 'version':56","created_at":"2026-04-15T18:38:43.282145+00:00","updated_at":"2026-04-16T15:54:45.901964+00:00","problems":[{"fix":"Change the import statement from `from json_logic_qubit import jsonLogic` (or similar) to `from json_logic import jsonLogic`.","cause":"The Python package `json-logic-qubit` exposes its main functionality via the `json_logic` module, not `json_logic_qubit` directly.","error":"ModuleNotFoundError: No module named 'json_logic_qubit.json_logic'"},{"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.","cause":"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.","error":"TypeError: 'dict_keys' object does not support indexing"},{"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.","cause":"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`.","error":"ValueError: Invalid JsonLogic rule (or similar error message indicating an unknown/malformed operator)"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.9.1","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/qubitproducts/json-logic-py","docs":null,"changelog":null,"pypi":"https://pypi.org/project/json-logic-qubit/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}