JSON Schema Validation
Verifies JSON data against specified validation criteria and expected structure. This evaluation ensures that JSON content adheres to predefined schemas and validation rules.
Evaluation Using Interface
Input:
- Required Inputs:
- actual_json: The JSON content column to validate.
- expected_json: The reference JSON schema column to validate against.
- Configuration Parameters:
- validations: List of strings - Specific validation criteria to apply.
Output:
- Result: Passed / Failed
Interpretation:
- Passed: Indicates that the
actual_json
content successfully conforms to the structure and rules defined in theexpected_json
schema, according to the specifiedvalidations
. - Failed: Signifies that the
actual_json
content does not match theexpected_json
schema based on the specifiedvalidations
(e.g., missing required fields, incorrect data types, invalid structure)
Evaluation Using Python SDK
Click here to learn how to setup evaluation using the Python SDK.
Input Type | Parameter | Type | Description |
---|---|---|---|
Required Inputs | actual_json | object or string | The JSON content to validate. |
expected_json | object or string | The reference JSON schema to validate against. | |
Configuration Parameters | validations | list[string] | List of specific validation criteria (e.g., ["type_check"] ). |
Output | Type | Description |
---|---|---|
Result | float | Returns 1.0 if the JSON matches the schema (Pass), 0.0 otherwise (Fail). |
What to do when JSON Scheme Validation Fails
Start with a schema review by checking the actual JSON structure against the expected schema and ensuring alignment with the defined validation criteria. Then, review the validation criteria to confirm that they are appropriate for the use case, complete in covering all necessary constraints, and free from conflicting rules that might cause unnecessary validation failures.
Differentiating JSON Scheme Validation from Is JSON Eval
While both evaluations handle JSON, their scope and complexity differ. JSON Schema Validation ensures that a JSON structure adheres to specific rules and validation criteria, while Is JSON simply checks whether the content is a valid JSON format.
JSON Schema Validation involves a more complex process, verifying structure, data types, and constraints against predefined schemas, whereas Is JSON performs a basic syntax check for correct JSON formatting.