n8n-io/n8n · error
Expected a JSON array of objects, got a single value or…
Error message
Expected a JSON array of objects, got a single value or object
What it means
parseJson only accepts a top-level JSON array of row objects. This fires when the parsed value is a single object, a primitive, or anything else non-array — e.g. the file holds one record instead of a list.
Solutions
- Wrap the payload in a top-level array, e.g. turn {"a":1} into [{"a":1}]
- If a single object is intended, convert it to a one-element array in the source file
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/@n8n/instance-ai/src/parsers/structured-file-parser.ts:325 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/e4f0652c7aea391a.
Report an issue: GitHub.
Appendix: source
Thrown at packages/@n8n/instance-ai/src/parsers/structured-file-parser.ts:325
}
}
return { rawHeaders, allRows: dataRows };
}
function parseJson(content: string): {
rawHeaders: string[];
allRows: Array<Record<string, unknown>>;
} {
let parsed: unknown;
try {
parsed = JSON.parse(content);
} catch {
throw new Error('Invalid JSON: failed to parse');
}
if (!Array.isArray(parsed)) {
throw new Error('Expected a JSON array of objects, got a single value or object');
}
if (parsed.length === 0) {
return { rawHeaders: [], allRows: [] };
}
// Collect all keys across all objects (preserving order of first appearance)
const keySet = new Set<string>();
for (const item of parsed) {
if (typeof item !== 'object' || item === null || Array.isArray(item)) {
throw new Error('JSON array items must be flat objects (not arrays, nulls, or primitives)');
}
const dangerousKey = hasDangerousKey(item as Record<string, unknown>);
if (dangerousKey) {
throw new Error(`Dangerous key "${dangerousKey}" found in JSON data`);
}
for (const key of Object.keys(item as Record<string, unknown>)) {
keySet.add(key);View on GitHub (pinned to 5ac6606e81)