# JsonDataSourceOptions (@salmonui/data/json)

> The JsonDataSourceOptions interface of @salmonui/data/json.

Canonical: https://salmonui.dev/docs/reference/data/json/JsonDataSourceOptions

```ts
import type { JsonDataSourceOptions } from '@salmonui/data/json';
```

Also exported from `@salmonui/data`.

Entry index: https://salmonui.dev/docs/reference/data/json (Markdown with every symbol of the entry: https://salmonui.dev/docs/reference/data/json.md).

## Reference

Kind: interface

```ts
interface JsonDataSourceOptions {
    readonly url?: string;
    readonly fetch?: FetchLike;
    readonly headers?: Readonly<Record<string, string>> | (() => Readonly<Record<string, string>>);
    readonly batch?: boolean;
    readonly transport?: JsonTransport;
    readonly key: string;
    readonly fields?: readonly string[];
    readonly rowShape?: 'tuple' | 'object';
    readonly fieldOf?: (columnId: ColumnId) => string;
    readonly columnIdOf?: (field: string) => ColumnId;
    readonly paging?: PagingStrategy;
    readonly policy?: RequestPolicy;
    readonly scheduler?: Scheduler;
    readonly optimistic?: boolean;
    readonly versionField?: string;
    readonly capabilities?: Partial<DataSourceCapabilities>;
    readonly onRequest?: (event: RequestEvent) => boolean | void;
    readonly onResponse?: (event: ResponseEvent) => WireResponse | void;
    readonly onError?: (event: RequestErrorEvent) => void;
}
```

Members (19):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `url` | `readonly url?: string;` | optional | Endpoint for the default fetch transport. Ignored when `transport` is set. |
| `fetch` | `readonly fetch?: FetchLike;` | optional |  |
| `headers` | `readonly headers?: Readonly<Record<string, string>> \| (() => Readonly<Record<string, string>>);` | optional |  |
| `batch` | `readonly batch?: boolean;` | optional | Multiplex same-tick requests into one `{ v: 1, batch }` POST. Default true. |
| `transport` | `readonly transport?: JsonTransport;` | optional | Custom transport (GraphQL bridge, WebSocket, in-process handler, ...). |
| `key` | `readonly key: string;` |  | Primary key field. |
| `fields` | `readonly fields?: readonly string[];` | optional | Requested field list (`select`). Required for tuple rows: rows are the decoded tuples in this order. Without it rows are objects. |
| `rowShape` | `readonly rowShape?: 'tuple' \| 'object';` | optional | Default `tuple` when `fields` is set, else `object`. |
| `fieldOf` | `readonly fieldOf?: (columnId: ColumnId) => string;` | optional | columnId to server field. Default identity. |
| `columnIdOf` | `readonly columnIdOf?: (field: string) => ColumnId;` | optional | server field to columnId, for errors and aggregates. Default: inverse of `fieldOf` over the query, else identity. |
| `paging` | `readonly paging?: PagingStrategy;` | optional |  |
| `policy` | `readonly policy?: RequestPolicy;` | optional |  |
| `scheduler` | `readonly scheduler?: Scheduler;` | optional |  |
| `optimistic` | `readonly optimistic?: boolean;` | optional | Default: true for `batch` and `cell` writes, false otherwise. |
| `versionField` | `readonly versionField?: string;` | optional | Row field holding the row version (ETag); forwarded as expected version on change/remove. |
| `capabilities` | `readonly capabilities?: Partial<DataSourceCapabilities>;` | optional |  |
| `onRequest` | `readonly onRequest?: (event: RequestEvent) => boolean \| void;` | optional | Cancelable (`return false`): the request rejects with `RequestCanceledError`. |
| `onResponse` | `readonly onResponse?: (event: ResponseEvent) => WireResponse \| void;` | optional | Called with every successful protocol response before the source decodes it. Returning a response object replaces the response for this request (e.g. to rewrite rows or `total`); any other return value keeps it. Return a new object: the cache keeps the original response and a cache hit runs the hook again. |
| `onError` | `readonly onError?: (event: RequestErrorEvent) => void;` | optional |  |
