{"id":19126301,"url":"https://github.com/santanusinha/json-rules","last_synced_at":"2025-07-24T21:36:42.174Z","repository":{"id":45288700,"uuid":"68243583","full_name":"santanusinha/json-rules","owner":"santanusinha","description":"JSON serializable rules to match Jackson JsonNodes using JSON Pointers","archived":false,"fork":false,"pushed_at":"2025-07-01T10:47:46.000Z","size":333,"stargazers_count":27,"open_issues_count":4,"forks_count":22,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-07-01T11:46:22.994Z","etag":null,"topics":["evaluation","jackson","json","json-pointer","json-serializable-rules","predicates","rule-engine","rule-eva","rules"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/santanusinha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-09-14T21:09:23.000Z","updated_at":"2025-07-01T10:47:51.000Z","dependencies_parsed_at":"2024-11-09T05:39:11.472Z","dependency_job_id":"6b819f4e-18c5-4e5f-888f-49434caa1c9f","html_url":"https://github.com/santanusinha/json-rules","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/santanusinha/json-rules","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santanusinha%2Fjson-rules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santanusinha%2Fjson-rules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santanusinha%2Fjson-rules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santanusinha%2Fjson-rules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/santanusinha","download_url":"https://codeload.github.com/santanusinha/json-rules/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santanusinha%2Fjson-rules/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266905687,"owners_count":24004149,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["evaluation","jackson","json","json-pointer","json-serializable-rules","predicates","rule-engine","rule-eva","rules"],"created_at":"2024-11-09T05:39:03.880Z","updated_at":"2025-07-24T21:36:42.163Z","avatar_url":"https://github.com/santanusinha.png","language":"Java","readme":"# Json Rules [![Build Status](https://travis-ci.org/santanusinha/json-rules.svg?branch=master)](https://travis-ci.org/santanusinha/json-rules)\n\nJSON serializable rules to match Jackson JsonNodes with JSONPath expressions.\n\n###### Rule\n```json\n   {\n      \"type\": \"equals\",\n      \"value\": \"happy\",\n      \"path\": \"$.mood\"\n   }\n```\n\n###### Payload\n```json\n   {\n      \"name\": \"John Doe\",\n      \"mood\": \"happy\"\n   }\n```\n\nPayload would match the rules when evaluated\n\n\n## Getting Started\n### Installation\n\nMaven repo\n```\n  \u003cdependency\u003e\n    \u003cgroupId\u003eio.appform.rules\u003c/groupId\u003e\n    \u003cartifactId\u003ejson-rules-core\u003c/artifactId\u003e\n    \u003cversion\u003eLATEST\u003c/version\u003e\n  \u003c/dependency\u003e\n```\n\n### Usage\n```java\n    // Build expression with java objects\n    Expression expression = LessThanExpression.builder()\n                                .path(\"$.value\")\n                                .value(30)\n                                .build();\n    // Or read from serialized json sources\n    Expression expression = (new ObjectMapper()).readValue(expressionJson, Expression.class)\n    \n    // Get json payload to be evaluated\n    JsonNode jsonNode = objectMapper.readTree(productJson);\n    \n    boolean matches = expression.evaluate(jsonNode);\n```\n##### Operators\n\n\n###### General\n\n * equals\n * not_equals\n * less_than \n * greater_than\n * less_than_equals\n * greater_than_equals\n * between (half-closed with lower bound included)\n\n```json\n   {\n      \"type\": \"equals\",\n      \"value\": \"happy\",\n      \"path\": \"$.mood\"\n   }\n```\n\n###### Composite/Boolean operators\n * and\n * not\n * or\n```json\n   {\n      \"type\": \"and\",\n      \"children\": [\n          {\n             \"type\": \"equals\",\n             \"value\": \"happy\",\n             \"path\": \"$.mood\"\n          },\n          {\n             \"type\": \"less_than\",\n             \"value\": 1000,\n             \"path\": \"$.product.cost\"\n          }\n      ]\n   }\n```\n###### Collection Search\n\n * not_in\n * in\n * contains_any\n * contains_all\n\n```json\n   {\n      \"type\": \"in\",\n      \"path\": \"$.mood\",\n      \"values\": [\n        \"happy\",\n        \"sad\"\n      ]\n   }\n```\n\n###### Strings\n * empty\n * not_empty\n * starts_with\n * ends_with\n * matches\n\nThe string operations of `starts_with`, `ends_with` and `matches` support case insensitive comparison also. Default comparison is case sensitive.\n\n```json\n    {\n        \"type\": \"matches\",\n        \"path\": \"$.s1\",\n        \"value\": \".* WORLD\",\n        \"ignoreCase\" : true\n    }\n```\n\n###### Path validations\n * exists\n * not_exists\n \n\n##### Default results\n\nFor unstructured json evaluation you can specify a defaultResult value.\nThe default value would be the evaluation result if `path` doesn't exist in the evaluation payload.\n\n```json\n   {\n      \"type\": \"equals\",\n      \"value\": \"happy\",\n      \"path\": \"$.mood\",\n      \"defaultResult\": true\n   }\n```\n\n##### Pre-Operations\n\nPre-operations are pre-evaluation mutations that can be applied to payload.\n \n * Datetime\n     * Epoch - Mutation rules for unix timestamp\n     * DateTime - Mutation rules for textual dates\n * Numeric\n     * Divide\n     * Multiply\n     * Sum\n     * Difference\n     * modulo\n * Array\n     * size\n * String\n     * length\n     * sub_str\n\n```json\n    {\n        \"type\": \"in\",\n        \"path\": \"$.time\",\n        \"preoperation\": {\n          \"operation\": \"epoch\",\n          \"operand\": \"week_of_month\",\n          \"zoneOffSet\": \"+05:30\"\n        },\n        \"values\": [\n          2,\n          4\n        ]\n    }\n```\n  \n##### Path based comparisons\n\nThese allow comparison of dynamic values. Using `\"extractValueFromPath\" : true`, indicates the value to be used for comparison has to be extracted from `value` json path.\n\n``` json\n    {\n        \"type\": \"matches\",\n        \"path\": \"$.s1\",\n        \"value\": \"$.s2\",\n        \"extractValueFromPath\" : true\n    }\n```\n\n### Debugging\n\nDebugging support is provided to understand exact reasons of rule failures for any given context. This support is extended across all the available operators.\n\n## Advanced Configurations\n\n### Performance \u003c\u003e Safety Preference\nThere is a performanceSafetyPreference option that can be set to either SPEED or SAFETY depending upon your needs. \u003cbr\u003e\nIf your application doesn't use an infinite set of json paths, it is recommended to set this option to SPEED. \u003cbr\u003e\nIf on the other hand, your application uses an infinite or unbounded number of json paths (at least 1 million or more), then to prevent json-rules \nfrom using more than a finite amount of heap memory for caching the json path expressions, you may want to set this option to SAFETY. \u003cbr\u003e\nIt can be set to SPEED as follows\n\n```java\nJsonRulesConfiguration.configure(PerformanceSafetyPreference.SPEED);\n```\n\n### Support for complex JSONPath expressions\nFilter expressions and UDF invocations are supported for JSONPath expressions. This allows for more complex evaluations and transformations on the JSON data.\nFor more details on which UDFs are supported, please refer to the [UDFs documentation](https://github.com/json-path/JsonPath?tab=readme-ov-file#functions)\nFor examples, you can refer to this [test class](./src/test/java/io/appform/rules/jsonpath/JsonPathComplexExpressionsTest.java).\n\nTo enable this feature, you need to set the `enableComplexJsonPathExpressions` flag in the configuration as follows:\u003cbr\u003e\n```java\nJsonRulesConfiguration.enableComplexJsonPathExpressions(true);\n```\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsantanusinha%2Fjson-rules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsantanusinha%2Fjson-rules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsantanusinha%2Fjson-rules/lists"}