json-logic-py is a Python implementation of JsonLogic, a lightweight JSON-based rules engine. It allows users to build complex logic rules using a JSON structure, serialize them, and execute them in Python to evaluate data. The current version is 0.6.3, and it appears to be in a stable maintenance phase with infrequent updates, requiring Python 3.6+.
pip install json-logicVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define a JsonLogic rule using a Python dictionary and evaluate it against a data context. It shows a basic boolean evaluation and an example using the 'var' operator to access data.
Review existing rules that use the `in` operator and ensure they are intended to operate on lists. If string substring checking is needed, implement it with custom logic or different operators.
Always consult the official JsonLogic specification or examples to ensure correct rule syntax, especially for complex or nested conditions.
Sanitize or validate incoming rules. Consider implementing limits on rule complexity (e.g., nesting depth, number of operations) if rules are user-provided.
Ensure `json_logic.add_operation('my_operator', my_function)` is called for each custom operator before evaluating any rules that use it.Upgrade the `json-logic` library to a newer version or a compatible fork that has addressed this Python 3 incompatibility, or convert the `dict_keys` object to a list before indexing if modifying the library's source.
Add `from json_logic import jsonLogic` at the beginning of your Python script or module to import the function.
Install the library using pip: `pip install json-logic` or `pip install json-logic-py` (depending on the project's pypi name, `json-logic` is the correct one for nadirizr's project). Correct the import statement if there's a typo.
Check the spelling of the operator in your JSON rule against the list of supported operators (e.g., from jsonlogic.com or the library's documentation). If it's a custom operator, ensure it has been correctly added to the operations registry.
No dependency data recorded yet.