# json_as_object

## Description

Whole JSON objects as single-column JSON rows, optionally enclosed in an outer array. The target must have one compatible JSON column. Objects retain their JSON structure.

Input only. Select it with `FORMAT json_as_object`. Names ignore ASCII case; use the snake_case name shown here.

Each source object is the complete value of one JSON column. Its member names are not mapped to separate table columns. Input can contain consecutive objects or an outer array of objects.

The destination must select one compatible JSON column. Use a typed JSON declaration when selected paths inside each object need native validation. Ordinary row JSON settings do not apply to this whole-object codec.

```text
INSERT INTO table [(columns)] [SETTINGS ...] FORMAT json_as_object
<data>
```

## Example usage

```sql
SELECT name,is_input,is_output FROM system.formats WHERE name='json_as_object' FORMAT csv;
```

```text
"json_as_object",1,0
```

Example input for a single target column:

```text
{"id":7}
{"id":8}
```

## Format settings

Use a statement `SETTINGS` clause; these options are not persisted by `SET`.

| Setting       | Type     | Default | Meaning                                                                                  |
| ------------- | -------- | ------- | ---------------------------------------------------------------------------------------- |
| `snappy_mode` | `String` | `basic` | Read Snappy client files as basic (Hadoop blocks) or framed (standard streaming format). |

## Load rows

Run the INSERT request separately; its remaining bytes are input data.

```sql
CREATE TABLE document_input(doc JSON);
```

```text
OK
```

```sql
INSERT INTO document_input FORMAT json_as_object
{"id":7}
```

```text
OK
```

```sql
SELECT doc FROM document_input FORMAT json_each_row;
```

```text
{"doc":{"id":7}}
```
