Is JSON

Determines whether output text conforms to valid JSON format, catching structural errors that break downstream parsing.

Is JSON checks whether a piece of text is valid JSON, catching structural errors before they break a downstream parser. Run it wherever a model is expected to return structured JSON output.

What it does

Is JSON is a deterministic, rule-based eval. It parses the provided text and checks whether it’s valid JSON.

Input

Required InputTypeDescription
textstringThe provided content to be evaluated for JSON validity

Output

FieldTypeDescription
ResultPass / FailPass means the provided content is valid JSON; Fail means it’s not
ReasonstringA plain-language explanation of the evaluation

Run it from code

Call evaluate() with the template name and the eval’s required inputs. It returns the score and the reason.

from fi.evals import evaluate

result = evaluate(
    "is_json",
    text='{"name": "Alice", "age": 30, "is_member": true}',
)

print(result.score)
print(result.reason)
import { evaluate } from "@future-agi/ai-evaluation";

const result = await evaluate(
  "is_json",
  {
    text: '{"name": "Alice", "age": 30, "is_member": true}'
  }
);

console.log(result);

When to use

Run Is JSON wherever downstream code parses the model’s output as JSON.

  • Text outputs feeding a json.loads or JSON.parse call in your pipeline
  • API responses where the model generates a structured payload
  • Regression checks after a prompt change, to confirm formatting instructions still hold

What to do when Is JSON fails

Identify common structural problems, such as missing commas, misplaced brackets, or incorrect key-value formatting, and correct them. To prevent future errors, implement automated checks within the system to detect and resolve formatting issues before processing.

Was this page helpful?

Questions & Discussion