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.
INSERT INTO table [(columns)] [SETTINGS ...] FORMAT json_as_string
<data>Example usage
SELECT name,is_input,is_output FROM system.formats WHERE name='json_as_string' FORMAT csv;"json_as_string",1,0Example input for a single target column:
{"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.
CREATE TABLE document_input(doc String);OKINSERT INTO document_input FORMAT json_as_string
{"id":7}OKSELECT doc FROM document_input FORMAT json_each_row;{"doc":"{\"id\":7}"}