Choose JSON declarations
Use plain JSON when any validated JSON document is acceptable. It can hold an object, array or scalar.
Use JSON(path Type, ...) when selected fields need declared types and dotted projection. This form requires an object and retains members that were not declared as typed paths.
Defaults and missing paths
A missing or explicit-null typed path receives the type's default. For a number this is usually zero; Nullable paths remain NULL. Choose Nullable when the distinction between missing and zero matters.
Paths are case-sensitive and cannot duplicate or overlap a declared parent. A scalar parent where an object is required is rejected.
Example
CREATE TABLE documents(doc JSON(id UInt64, comment Nullable(String)));
INSERT INTO documents VALUES ('{"id":7}');SELECT doc.id, doc.comment
FROM documents
FORMAT csv;7,\NThe id has a native integer contract, while an absent comment remains missing. See JSON for nested typed paths and JSON functions for document operations.