About Using JSONPath to Write Semantic Model Custom Rule Queries
JSONPath is the query language you use to create custom consistency check rules for your semantic model. JSONPath allows you to create user-defined rules that scan your semantic model's objects for violations of business and data-quality constraints.
You write custom consistency check rules as indefinite queries so they can match zero, one, or many nodes across evolving models, making them ideal for consistency and limiting work flows.
Definite Versus Indefinite Queries
Note these differences between definite and indefinite queries:
- Definite paths select at most one node, and implementations typically return a single value or null when using definite paths. This is the “single-target” form.
- Indefinite paths can select zero, one, or many nodes and return a collection of matches, often as a list or array. Filters, wildcards, deep-scan, slices, and multi-index selectors make a query indefinite.
Why Custom Consistency Checks Require Indefinite Queries
Custom consistency checks require indefinite queries for these reasons:
- Comprehensive scanning - Consistency checks need to find not just one but all offending instances across the model. Therefore queries must be able to return multiple matches in a single evaluation.
- Schema and version resilience - As a semantic model evolves, for example, with added properties, reordered arrays, and new nesting, indefinite queries remain valid because they rely on patterns and not fixed positions.
- Clean reporting semantics - An indefinite query naturally maps to “N matches = N reported findings”, while zero matches cleanly represent “no issue” without errors or special cases.
Tips and Troubleshooting
- When you create a rule, use the Validate button in the Custom Rules dialog to validate your query's syntax. Use a small sample of objects to sanity-check selection and result cardinality.
- Be sure to confirm result cardinality. Expect arrays, and if a rule returns a single scalar, adjust to a filter or wildcard to make it indefinite.
- For large objects, narrow expensive scans by replacing
$..with subtree roots like$.presentationTable.hierarchieswhenever possible.
Resources
Oracle assumes that you're familiar with JSONPath and how to write valid JSONPath queries.
If you're new to JSONPath, use these resources to help you learn how to write your JSONPath queries.
See also JSONPath Custom Consistency Check Query Examples.
| Resource | Description |
|---|---|
| Official specification (RFC 9535) | The normative IETF standard for JSONPath syntax, selectors, filters, evaluation semantics, and conformance expectations. |
| Jayway JsonPath (Java) README | A popular implementation with practical syntax, operators, examples, and API usage details. |
| Hevo Data | A concise tutorial-style overview with examples and filter usage. |
| REST API Tutorial: | A guide to JSONPath basics and common querying patterns. |
| JSONPath Online Evaluator | An evaluator for prototyping expressions against sample JSON. |
| Site24x7 JSON Path Evaluator | An evaluator/validator with an interactive results panel. |