> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-8c05c8a2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Documentation for the JSONAsString format

# JSONAsString

| Input | Output | Alias |
| ----- | ------ | ----- |
| ✔     | ✗      |       |

<h2 id="description">
  Description
</h2>

In this format, a single JSON object is interpreted as a single value.
If the input has several JSON objects (which are comma separated), they are interpreted as separate rows.
If the input data is enclosed in `[]`, it is interpreted as an array of JSON objects.

<Note>
  This format can only be parsed for a table with a single field of type [String](/reference/data-types/string).
  The remaining columns must be set to either [`DEFAULT`](/reference/statements/create/table#default) or [`MATERIALIZED`](/reference/statements/create/view#materialized-view),
  or be omitted.
</Note>

Once you serialize the entire JSON object to a String you can use the [JSON functions](/reference/functions/regular-functions/json-functions) to process it.

<h2 id="example-usage">
  Example usage
</h2>

<h3 id="basic-example">
  Basic example
</h3>

```sql title="Query" theme={null}
DROP TABLE IF EXISTS json_as_string;
CREATE TABLE json_as_string (json String) ENGINE = Memory;
INSERT INTO json_as_string (json) FORMAT JSONAsString {"foo":{"bar":{"x":"y"},"baz":1}},{},{"any json stucture":1}
SELECT * FROM json_as_string;
```

```response title="Response" theme={null}
┌─json──────────────────────────────┐
│ {"foo":{"bar":{"x":"y"},"baz":1}} │
│ {}                                │
│ {"any json stucture":1}           │
└───────────────────────────────────┘
```

<h3 id="an-array-of-json-objects">
  An array of JSON objects
</h3>

```sql title="Query" theme={null}
CREATE TABLE json_square_brackets (field String) ENGINE = Memory;
INSERT INTO json_square_brackets FORMAT JSONAsString [{"id": 1, "name": "name1"}, {"id": 2, "name": "name2"}];

SELECT * FROM json_square_brackets;
```

```response title="Response" theme={null}
┌─field──────────────────────┐
│ {"id": 1, "name": "name1"} │
│ {"id": 2, "name": "name2"} │
└────────────────────────────┘
```

<h2 id="format-settings">
  Format settings
</h2>
