# JSON containing an empty array

**A single object shape.**

## Input

```json
{
  "id": 1,
  "tags": [],
  "metadata": {}
}
```

## TypeScript

```typescript
export interface Root {
  id: number;
  tags: unknown[];
  metadata: Record<string, unknown>;
}
```

## Zod

```typescript
import { z } from 'zod';

export const RootSchema = z.object({
  id: z.number(),
  tags: z.array(z.unknown()),
  metadata: z.record(z.string(), z.unknown()),
});
```

## Warnings

### Empty array — element type unknown (caution)

`tags` is empty in the sample, so there is nothing to infer an element type from. The output uses `unknown` rather than inventing a shape.

**Fix:** Supply a sample where these arrays contain at least one element.

### Empty object — shape unknown (caution)

`metadata` is empty in the sample. The output uses `Record<string, unknown>`, which accepts anything.

**Fix:** Supply a populated example of these objects.

### Whole numbers are still `number` (info)

Every numeric value in the sample was a whole number, but JSON has a single number type and cannot express the difference. The output uses `number`.

**Fix:** If a field is genuinely an integer, tighten it by hand: `z.number().int()`.

---

Canonical URL: https://json-to-types.gumballtools.com/types/json-with-empty-array
JSON API: `POST https://json-to-types.gumballtools.com/api/v1/convert`
MCP endpoint: `https://json-to-types.gumballtools.com/api/mcp`
