# ListOptionsJsonFormat

**Kind:** Interface

**Source:** [`packages/platform-fastify/interfaces/external/fastify-static-options.interface.ts`](https://github.com/nestjs/nest/blob/master/packages/platform-fastify/interfaces/external/fastify-static-options.interface.ts#L48)

**Part of:** [Platform Fastify](subsystem-packages-platform-fastify)

`ListOptionsJsonFormat` configures directory listing output for the Fastify static file integration when JSON responses are required. It fixes the `format` discriminator to `'json'` and requires a `render` function that generates the listing response.

## Properties

| Property | Type |
|---|---|
| `format` | `'json'` |
| `render` | `ListRender` |

## Diagram

```mermaid
graph LR
  A[Fastify Static Directory Listing] --> B[ListOptionsJsonFormat]
  B --> C[format: 'json']
  B --> D[render: ListRender]
  D --> E[JSON Directory Listing Response]
```

## Usage

```ts
import type { ListOptionsJsonFormat } from './interfaces/external/fastify-static-options.interface';

const listOptions: ListOptionsJsonFormat = {
  format: 'json',
  render: (request, reply, files) => {
    return reply.send({
      files: files.map((file) => ({
        name: file.name,
        path: file.path,
      })),
    });
  },
};

// Pass listOptions to the Fastify static plugin configuration.
```

## AI Coding Instructions

- Set `format` exactly to `'json'`; it acts as the discriminator for this listing configuration.
- Always provide a `render` implementation compatible with the `ListRender` type.
- Return or send a JSON-serializable response from `render`.
- Use this interface only for directory listing behavior in the Fastify static integration.
- Avoid mixing JSON-specific options with other listing format configurations.
