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.
INSERT INTO table [(columns)] [SETTINGS ...] FORMAT json_as_object
<data>Example usage
SELECT name,is_input,is_output FROM system.formats WHERE name='json_as_object' FORMAT csv;"json_as_object",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 JSON);OKINSERT INTO document_input FORMAT json_as_object
{"id":7}OKSELECT doc FROM document_input FORMAT json_each_row;{"doc":{"id":7}}