Verified Developer Solution • 100% OfflineFix "data must be array" in JSON Schema
Resolve type mismatch errors in JSON Schema where an object is provided instead of an array.
The Problem (Error Root Cause)Exception
You are encountering a validation error stating "data must be array". Your JSON data is structured as an object `{}` when the schema expects a list `[]`.
Identified via runtime validation & stack traces
The Solution (Step-by-Step Fix)Verified
Wrap your object in an array or modify the schema to accept both types if single items are permitted.
Deterministic, non-destructive resolution
Code Standard: Bad Pattern vs Verified Fix
Live SyntaxAnti-Pattern vs Verified Fix
1// ❌ Bad: Sending object when array expected2{ "item": 1 } 3 4// ✅ Good: Sending an array5[ { "item": 1 } ]Test and resolve this using JSON Schema Validator
Execute directly in your browser memory. Zero API keys, zero network tracking, completely client-side.
Frequently Asked Questions
Q:Can a schema accept both object and array?
Yes, use `type: ["object", "array"]` or `oneOf` to support both structures.
Q:How can I fix the JSON?
Use our JSON Formatter and Schema Validator to preview your changes in real time.