> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# JSON

> Read JSON records or documents and write one JSON object per line.

How-to guide

The JSON connector reads JSON objects and writes one object per line. It supports append and whole-dataset overwrite.

## Before you start

Prepare storage and a client connection using [Read and write files](https://docs.e6data.com/transformation/connectors/files.md). For the read example, save these two lines in an accessible `.json` file:

```jsonl theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"order_id":1,"amount":12.5}
{"order_id":2,"amount":7.5}
```

## Read data

Use an explicit schema when fields must have stable types:

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
CREATE OR REPLACE TEMP VIEW json_orders (
  order_id BIGINT,
  amount DOUBLE
)
USING json
OPTIONS (
  path '<input-json-file-or-folder>',
  pathGlobFilter '*.json'
);

SELECT order_id, amount FROM json_orders ORDER BY order_id;
```

Expect `(1, 12.5)` and `(2, 7.5)`. If the column list is omitted, the reader discovers a schema from a bounded sample. JSON does not accept the CSV/TSV `inferSchema` option.

## Read a JSON document

For a formatted object or a top-level array of objects, set `multiLine 'true'`:

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
CREATE OR REPLACE TEMP VIEW json_document_orders (
  order_id BIGINT,
  amount DOUBLE
)
USING json
OPTIONS (path '<json-document-file>', multiLine 'true');

SELECT * FROM json_document_orders ORDER BY order_id;
```

Every record must be an object. The whole document must fit the schema inspection and read budgets for this mode.

## Write data

Use the `spark` connection from the shared file guide. The writer always produces JSON Lines, including when the input came from a JSON array.

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
output_path = "<mounted-json-output-directory>"
orders = spark.createDataFrame(
    [(1, 12.5), (2, 7.5)], "order_id BIGINT, amount DOUBLE"
)

orders.write.format("json").mode("overwrite").save(output_path)

written = (
    spark.read.format("json")
    .schema("order_id BIGINT, amount DOUBLE")
    .load(output_path)
)
written.orderBy("order_id").show()
assert written.count() == 2
```

Use `mode("append")` to add rows. SQL also supports a directory export:

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
INSERT OVERWRITE DIRECTORY '<mounted-json-output-directory>'
STORED AS JSONFILE
SELECT order_id, amount FROM json_orders;
```

Choose the client example or the SQL export for a destination. Both overwrite the active dataset.

## Options

| Option | Default | Read or write | Meaning |
| - | - | - | - |
| `multiLine` | `false` | Read | Parse a whole object or an array of objects as a document. |
| `mode` | `FAILFAST` | Read | Fail on invalid input. Other parsing modes are rejected. |
| `encoding` | UTF-8 | Both | Only UTF-8 is accepted. |

Use [shared read options](https://docs.e6data.com/transformation/connectors/files.md#read-options-shared-by-file-formats) for paths, file filtering, and storage access. The writer has no configurable JSON format options. It does not accept `multiLine`. Only uncompressed JSON output is supported.

## Data types and limits

JSON field names map to columns. JSON numbers, booleans, strings, nulls, arrays, and objects are interpreted through the selected schema. An explicit schema avoids type changes caused by a different inference sample.

Supported file suffixes are `.json`, `.jsonl`, and `.ndjson`. Match the suffix used by your input when setting `pathGlobFilter`. Header, delimiter, quote, and `nullValue` are not JSON options.

Row updates, deletes, and merges are not supported by this file sink. Use [Iceberg](https://docs.e6data.com/transformation/connectors/iceberg.md) or [Delta Lake](https://docs.e6data.com/transformation/connectors/delta.md) when those table operations are needed.

## Related guides

* [Read and write files](https://docs.e6data.com/transformation/connectors/files.md)
* [Read JSON files](https://docs.e6data.com/transformation/recipes/files/json-files.md)
* [Query JSON and nested data](https://docs.e6data.com/transformation/learn/json-and-nested.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.