Source: https://probeo.io/docs/en/structured-data/arrays/

# How to restructure this JSON-LD so it is a valid object or array?

`jsonld-invalid-root-structure` page

## The issue

A JSON-LD block whose root isn’t an object or an array of objects can’t be read at all. Every entity in it is lost to search engines, however well-formed the rest is, and the page shows no sign of it.

The cause is the shape of the block. A parser expects `{...}` or `[{...}, {...}]` at the root. A bare string or number, an array holding something other than objects, or two objects side by side with no array around them fails before any property is read.

## Scope

Each `<script type="application/ld+json">` block is checked on its own, and so is each item in a root array. A malformed block doesn’t affect the other blocks on the page.

## How to check you have it

-   **In probeo:** the page reports `JSON-LD node must be an object`, or `Empty or unparseable JSON-LD block`.
-   **By hand:** view the page source and look at the first character inside each JSON-LD script tag. It should be `{` or `[`, and every item in a `[...]` should be an object.
-   **With a validator:** paste the block into the [Schema Markup Validator](https://validator.schema.org/). Confirm it lists every entity you expect.

## The fix

Wrap the content in a valid root.

One entity is a single object with its own `@context` and `@type`. Several entities go in an array of objects, or in one object holding a `@graph`, which lets them share a single `@context`.

**Done when:** each block’s root is one object or one array of objects, and the check above comes back clean.

### Do not

-   Do not put a bare string or number at the root.
-   Do not leave several objects side by side without an array.
-   Do not assume a parser will work out the structure from the content.

## FAQ

### When should multiple entities be wrapped in an array versus using separate script tags?

Both approaches work. Arrays group related entities in a single block. Separate script tags isolate entities for independent processing. Arrays reduce markup but increase coupling.

### Does wrapping a single object in an array change how search engines interpret it?

No. Search engines process `{...}` and `[{...}]` identically when the array contains a single object. The array wrapper does not affect entity interpretation.

### What happens when the root structure is valid but deeply nested content is malformed?

Parsers may extract partial data from valid portions. Root-level validity does not guarantee complete interpretation, but it allows processing to begin.

### Can comments or whitespace before the opening brace cause structure failures?

No. JSON allows leading whitespace. Comments are not valid in JSON or JSON-LD and will cause syntax errors regardless of position.

### How do arrays affect @context scope?

They don’t share it. An array has nowhere to put a shared `@context`, so each object in it declares its own, and probeo checks each one. To declare it once for several entities, use a single object with a `@graph`: the nodes in the graph inherit its `@context`.

### What distinguishes an array structure error from an array content error?

Structure errors prevent the root from parsing as valid JSON-LD. Content errors occur when the array parses successfully but individual objects contain invalid schema properties.
