parseJsonTable
Syntax
parseJsonTable(json, [schema], [keyCaseSensitive=true])Arguments
-
json is a STRING scalar or vector containing JSON objects. If it is a STRING scalar, it can contain one or more JSON objects. JSON arrays and recursive JSON objects are not supported yet.
-
schema (optional) is a table that specifies the column names and types. It can contain the following columns:If schema is not specified, the function will automatically parse the schema based on the first 10 JSON objects.
Column
Description
name a string representing the column name type a string representing the column type. Currently, BLOB is not supported. format (optional) a string specifying the format of date or time columns. -
keyCaseSensitive (optional) indicates whether keys are case-sensitive. true (default) means case sensitive, false means case insensitive.
Details
Parses JSON objects into an in-memory table.
- When json is a string containing multiple JSON objects, each object will be converted to a row in the table.
- When json is a vector of strings, each element will be converted to a row in the table.
Examples
json1='{"ID":1, "NAME":"cc"}{"NAME":"dd"}'
parseJsonTable(json1)
output:
ID | NAME |
---|---|
1 | cc |
dd |
json2 = '{"col_test":"20190522150407"}'
schemaTB = table(["col_test"] as name, ["DATETIME"] as type, ["yyyyMMddHHmmss"] as format)
parseJsonTable(json2, schemaTB)
output: 2019.05.22T15:04:07
When json is a string containing two JSON objects:json3='{"ID":11, "NAME":"dd"}' schemaTB1 = table(["ID", "NAME", "col_test"] as name, ["INT", "STRING", "DATETIME"] as type, [,,"yyyyMMddHHmmss"] as format) parseJsonTable(concat([json2,json3]),schemaTB1)output:
ID | NAME | col_test |
---|---|---|
2019.05.22T15:04:07 | ||
11 | dd |
When json is a STRING vector:
parseJsonTable([json2,json3],schemaTB1)
output:
ID | NAME | col_test |
---|---|---|
2019.05.22T15:04:07 | ||
11 | dd |