parse_json
Aliases: parsejson (deprecated).
parse_json(value: string, [options(...)]?) -> variant
Parse the argument value as a JSON string.
The object or array that comes out is typically put into a column using make_col.
parse_json accepts one option, allow_duplicate_keys (see below).
Options
| Option | Type | Meaning |
|---|---|---|
| allow_duplicate_keys | bool | Applies to JSON inputs with duplicate keys. If true, the last value of the duplicate key is used. If false, the function returns null. Default is false. |
Domain
This is a scalar function (calculates a single output value for a single input row).
Categories
Examples
make_col json:parse_json(string(payload))
Make a new column, of type variant, containing the contents of field payload parsed as JSON.
make_col json:object(parse_json('{ "k1": "v1", "k2": [ "one", "two" ], "k3": { "key 4": ["five"] } }'))
Make a new column containing the specified string parsed as JSON. The result is coerced to object to ensure it has the desired type.
extract_regex log, /JSON payload: (?P<StringPayload>{.*})/
make_col payload:parse_json(StringPayload)
Extract the JSON portion of the string log into new field StringPayload, then parse it as JSON.
make_col json:parse_json('{ "k1": "v1", "k1": "v2" }', options(allow_duplicate_keys: true))
Make a new column containing the specified string parsed as JSON. By default, because parse_json does not allow duplicate keys,
the column would contain null. However, since allow_duplicate_keys is enabled, the column will instead contain {"k1": "v2"},
which is obtained from the last value that is assigned to the key in the source JSON.
Updated 8 days ago