# json_as_string

## Description

Whole JSON objects as single-column text rows, optionally enclosed in an outer array. The object text is the value of a String column.

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

Each source object becomes the complete text value of one selected String column. An outer array can contain several objects; their fields are not expanded into destination columns.

Use json_as_object when the stored value should be native JSON. This codec validates object framing but preserves object text as text, and does not use the ordinary row JSON settings.

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

## Example usage

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

```text
"json_as_string",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 String);
```

```text
OK
```

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

```text
OK
```

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

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