mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Document JSONAsString
This commit is contained in:
parent
875a0a04eb
commit
e2ca214699
@ -25,7 +25,8 @@ The supported formats are:
|
|||||||
| [Vertical](#vertical) | ✗ | ✔ |
|
| [Vertical](#vertical) | ✗ | ✔ |
|
||||||
| [VerticalRaw](#verticalraw) | ✗ | ✔ |
|
| [VerticalRaw](#verticalraw) | ✗ | ✔ |
|
||||||
| [JSON](#json) | ✗ | ✔ |
|
| [JSON](#json) | ✗ | ✔ |
|
||||||
| [JSONString](#jsonstring) | ✗ | ✔ |
|
| [JSONAsString](#json) | ✗ | ✗ |
|
||||||
|
| [JSONString](#jsonasstring) | ✔ | ✔ |
|
||||||
| [JSONCompact](#jsoncompact) | ✗ | ✔ |
|
| [JSONCompact](#jsoncompact) | ✗ | ✔ |
|
||||||
| [JSONCompactString](#jsoncompactstring) | ✗ | ✔ |
|
| [JSONCompactString](#jsoncompactstring) | ✗ | ✔ |
|
||||||
| [JSONEachRow](#jsoneachrow) | ✔ | ✔ |
|
| [JSONEachRow](#jsoneachrow) | ✔ | ✔ |
|
||||||
@ -507,6 +508,34 @@ Example:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## JSONAsString {#jsonasstring}
|
||||||
|
|
||||||
|
In this format, a single JSON object is interpreted as a single value. If input has several JSON objects (comma separated) they will be interpreted as a sepatate rows.
|
||||||
|
|
||||||
|
This format can only be parsed for table with a single field of type [String](../sql-reference/data-types/string.md). The remaining columns must be set to [DEFAULT](../sql-reference/statements/create/table.md#default) or [MATERIALIZED](../sql-reference/statements/create/table.md#materialized), or omitted. Once you collect whole JSON object to string you can use JSON fuctions to process it.
|
||||||
|
|
||||||
|
**Example**
|
||||||
|
|
||||||
|
Query:
|
||||||
|
|
||||||
|
``` sql
|
||||||
|
DROP TABLE IF EXISTS json_as_string;
|
||||||
|
CREATE TABLE json_as_string (json String) ENGINE = Memory;
|
||||||
|
INSERT INTO json_as_string FORMAT JSONAsString {"foo":{"bar":{"x":"y"},"baz":1}},{},{"any json stucture":1}
|
||||||
|
SELECT * FROM json_as_string;
|
||||||
|
```
|
||||||
|
|
||||||
|
Result:
|
||||||
|
|
||||||
|
``` text
|
||||||
|
┌─json──────────────────────────────┐
|
||||||
|
│ {"foo":{"bar":{"x":"y"},"baz":1}} │
|
||||||
|
│ {} │
|
||||||
|
│ {"any json stucture":1} │
|
||||||
|
└───────────────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## JSONCompact {#jsoncompact}
|
## JSONCompact {#jsoncompact}
|
||||||
## JSONCompactString {#jsoncompactstring}
|
## JSONCompactString {#jsoncompactstring}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user