Evaluation Using Interface

Input:

  • Required Inputs:
    • text: The input content column to be evaluated.

Output:

  • Result: Passed / Failed

Interpretation:

  • Passed: Indicates that the content in the text column is valid JSON format.
  • Failed: Signifies that the content in the text column is not valid JSON (e.g., syntax errors, missing brackets, improper structure).

Evaluation Using Python SDK

Click here to learn how to setup evaluation using the Python SDK.


Input TypeParameterTypeDescription
Required InputstextstringThe input content to be evaluated.

OutputTypeDescription
ResultboolReturns 1.0 if the content is valid JSON (Pass), 0.0 otherwise (Fail).

from fi.evals import EvalClient
from fi.testcases import TestCase
from fi.evals.templates import IsJson

test_case = TestCase(
    text='''
    {
        "name": "John Doe",
        "age": 30,
        "city": "New York",
        "hobbies": ["reading", "hiking"]
    }
    '''
)

template = IsJson()

evaluator = EvalClient(
    fi_api_key="your_api_key",
    fi_secret_key="your_secret_key",
    fi_base_url="<https://api.futureagi.com>"
)

response = evaluator.evaluate(eval_templates=[template], inputs=[test_case])

score = response.eval_results[0].metrics[0].value


What to do when JSON Validation Fails

Identify common structural problems, such as missing commas, misplaced brackets, or incorrect key-value formatting, should be corrected accordingly.

To prevent future errors, implementing automated checks within the system can help detect and resolve formatting issues before processing.


Differentiating Between Is JSON Eval with JSON Schema Validation

“Is JSON” evaluation focuses solely on structural validity, ensuring that data follows basic JSON syntax, such as correct use of brackets, commas, and quotes. In contrast, JSON Schema Validation goes beyond syntax by checking adherence to predefined schema rules, including data types, required fields, and value constraints.

The “Is JSON” check is simpler, as it only requires parsing the data, whereas JSON Schema Validation is more complex, involving validation against a structured schema.