All Recipes
StarVerified Developer Solution • 100% Offline
JSON Schema Validator

Fix "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 Syntax
Anti-Pattern vs Verified Fix
1// ❌ Bad: Sending object when array expected
2{ "item": 1 }
3
4// ✅ Good: Sending an array
5[ { "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.

Launch JSON Schema Validator

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.

Related Troubleshooting Guides

View Directory