Skip to content

Conversation

@gerrycampion
Copy link
Collaborator

@gerrycampion gerrycampion commented Aug 19, 2025

This pull request adds support for validating JSON files using JSONata queries, including the ability to use custom user-defined JSONata functions. It introduces a new rule type, updates the CLI and schema to support this functionality, and refactors data readers for JSON/USDM files. The most important changes are grouped below:

JSONata Rule Type and Processing:

  • Added a new JSONata rule type to RuleTypes and updated the schema and documentation to describe its usage, including examples and output mapping. [1] [2] [3] [4] [5]
  • Implemented JSONataProcessor to execute JSONata rules with support for custom functions loaded from external files, and integrated it into the rules engine. [1] [2] [3]

CLI and Argument Handling:

  • Added a new CLI option --jsonata-functions-path (-jfp) to specify a directory of custom JSONata function files, passed through validation and test workflows. [1] [2] [3] [4] [5] [6] [7] [8] [9]

Dataset Builder and Data Reader Refactoring:

  • Added JSONataDatasetBuilder and registered it in the factory for the new rule type. [1] [2] [3]
  • Renamed and refactored the USDM JSON reader to a generic JSONReader, updating the factory and references accordingly. [1] [2] [3]

Rule Parsing and Condition Handling:

  • Improved rule metadata parsing by converting spaces to underscores in keys and allowing conditions to be either dicts or strings for JSONata compatibility. [1] [2] [3] [4]

Dependency Updates and Miscellaneous:

  • Added jsonata-python as a dependency and updated flake8 version in pre-commit config. [1] [2]

These changes collectively enable flexible, user-extensible JSON validation via JSONata queries and custom functions, while improving the overall architecture for JSON data handling.

Copy link
Collaborator

@RamilCDISC RamilCDISC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please see the comments below.

@gerrycampion gerrycampion linked an issue Sep 8, 2025 that may be closed by this pull request
Copy link
Collaborator

@ASL-rmarshall ASL-rmarshall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm checking with Berber to confirm if she has the same expectations about Scope for JSONata rules - I'll update here when I get a response.

Copy link
Collaborator

@ASL-rmarshall ASL-rmarshall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only changes needed are to add the path attribute during pre-processing of the JSON and to remove two more redundant JSONata function files. The rest looks good.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As agreed at the daily stand-up meeting on 2025-10-09, a path attribute will be added to every instance of every class within the imported JSON so the get_path JSONata function will no longer be necessary. Please remove this file.

When adding the path attribute, no other attributes should be changed (or removed). I wrote a JSONata function to do this (here), but native python processing might be quicker.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is currently not used in any rule, so the file can be removed.

@gerrycampion gerrycampion merged commit 7b9f85c into main Oct 13, 2025
6 checks passed
@gerrycampion gerrycampion deleted the 1104-dataservice-and-datareader-for-arbitrary-json-files branch October 13, 2025 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants