parseJsonTable
Syntax
parseJsonTable(json, [schema], [keyCaseSensitive=true])
Details
Parses JSON objects into an in-memory table. JSON field values populate the corresponding output columns. Column names and data types are specified by schema or inferred when schema is omitted.
-
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. Without path, only the first JSON object in each element is parsed.
-
Each empty JSON object (
{}) occupies one row in the result.
Arguments
json is a STRING scalar or vector containing JSON objects.
schema (optional) is a table that specifies the column names and types.
If schema is not specified, the function will automatically infer the table schema from the first 10 JSON objects, then parse the input using that schema.
Fields that first appear in the 11th or a later object are ignored. To read these fields, specify them explicitly in schema.
If schema is omitted, the function raises an error when all input objects are empty ({}), or when the first 10 objects are empty.
schema can contain the following columns (name and type are required):
| Column | Description |
|---|---|
|
name |
a string representing the output column name |
|
type |
a string representing the column type. |
|
format |
a string specifying the format of date or time strings in the JSON input. |
|
path |
An optional column specifying field paths for the output columns. It is required for nested JSON objects. The following rules apply:
|
Field paths start at the outermost JSON object. The key names below are placeholders for actual keys; index is a zero-based array index.
| Syntax | Description |
|---|---|
|
key |
Reads the key field from the root object. |
|
|
Reads the child field from the parent object. Dots separate object levels. |
|
|
Reads the element at the specified index in array. |
|
|
Reads the child field from the specified element in array. |
|
|
Reads the field whose complete key name is key.name. |
|
|
Reads the child field from the object whose complete key name is key.name. |
|
|
Accesses the key1 object and then its key2 field. |
For key names containing special characters such as dots, spaces, or brackets, enclose the complete name in double quotes within brackets.
When path is specified:
-
The outermost JSON value must be an object, not an array such as
[{"id":1},{"id":2}]. Objects can contain arrays. -
If json is a STRING vector, each element must contain exactly one JSON object.
-
A missing path (including an array index out of range), JSON null, or a type conversion failure produces a NULL of the corresponding type. Arrays built from multiple paths retain the positions of missing values.
-
Invalid path syntax or incomplete JSON causes an error.
keyCaseSensitive (optional) indicates whether keys are case-sensitive, including keys at each level in path. The default value is true.
Returns
Returns an in-memory table.
Examples
Example 1: Parse a string containing multiple JSON objects into a table.
json1='{"ID":1, "NAME":"cc"}{"NAME":"dd"}'
parseJsonTable(json1)
| ID | NAME |
|---|---|
|
1 |
cc |
|
dd |
Example 2: Use format to specify the format of a date-time string.
json2 = '{"col_test":"20190522150407"}'
schemaTB = table(["col_test"] as name, ["DATETIME"] as type, ["yyyyMMddHHmmss"] as format)
parseJsonTable(json2, schemaTB)
| col_test |
|---|
|
2019.05.22T15:04:07 |
Example 3: 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)
| ID | NAME | col_test |
|---|---|---|
|
2019.05.22T15:04:07 |
||
|
11 |
dd |
Example 4: json is a STRING vector:
parseJsonTable([json2,json3],schemaTB1)
| ID | NAME | col_test |
|---|---|---|
|
2019.05.22T15:04:07 |
||
|
11 |
dd |
Example 5: Parse a string vector containing an empty JSON object, which is retained as one row.
home = ['{"Num":10, "Name":"Ronaldo","Goal":"3","MatchDay":"20120322"}','{"Num":3, "Name":"Carlos","Goal":"1","MatchDay":"20120322"}','{}'];
schemaLiga = table(["Num","Name","Goal","MatchDay"] as name, ["INT","STRING","INT","DATE"] as type, [,,,"yyyyMMdd"] as format);
formation = parseJsonTable(home,schemaLiga);
formation;
| Num | Name | Goal | MatchDay |
|---|---|---|---|
|
10 |
Ronaldo |
3 |
2012.03.22 |
|
3 |
Carlos |
1 |
2012.03.22 |
Example 6: Use path to combine nested trade fields with the receipt time from the root object.
quoteJson = [
'{"data":{"id":1,"price":10.1},"receivedTime":"2026.01.01 09:00:00.000"}',
'{"data":{"id":2,"price":10.2},"receivedTime":"2026.01.01 09:00:01.000"}'
]
quoteSchema = table(
["id", "price", "receivedTime"] as name,
["LONG", "DOUBLE", "TIMESTAMP"] as type,
["data.id", "data.price", "receivedTime"] as path
)
parseJsonTable(json=quoteJson, schema=quoteSchema)
| id | price | receivedTime |
|---|---|---|
|
1 |
10.1 |
2026.01.01T09:00:00.000 |
|
2 |
10.2 |
2026.01.01T09:00:01.000 |
Example 7: Read root fields and position fields from columnsAfter, ignore columnsBefore, and use format to specify the date string format.
positionJson = '{"OWNER":"TRADE","operType":"U","columnsAfter":{"L_DATE":"20250604","L_UNIT_ID":690792,"L_CURRENT_AMOUNT":5000},"columnsBefore":{"L_DATE":"20250603","L_UNIT_ID":690792,"L_CURRENT_AMOUNT":4500}}'
positionSchema = table(
["owner", "operation", "positionDate", "unitId", "amount"] as name,
["STRING", "STRING", "DATE", "LONG", "LONG"] as type,
["", "", "yyyyMMdd", "", ""] as format,
["OWNER", "operType", "columnsAfter.L_DATE", "columnsAfter.L_UNIT_ID", "columnsAfter.L_CURRENT_AMOUNT"] as path
)
parseJsonTable(json=positionJson, schema=positionSchema)
| owner | operation | positionDate | unitId | amount |
|---|---|---|---|---|
|
TRADE |
U |
2025.06.04 |
690792 |
5000 |
Example 8: Build array vectors for five bid and ask prices in level order, retaining NULL for the missing second bid price.
depthJson = '{"stock_code":"IF2403","buy_order_book":{"buy_first_price":3598.8,"buy_third_price":3598.4,"buy_fourth_price":3598.2,"buy_fifth_price":3598.0},"sell_order_book":{"sell_first_price":3599.0,"sell_second_price":3599.2,"sell_third_price":3599.4,"sell_fourth_price":3599.6,"sell_fifth_price":3599.8}}'
buyPricePaths = [
"buy_order_book.buy_first_price",
"buy_order_book.buy_second_price",
"buy_order_book.buy_third_price",
"buy_order_book.buy_fourth_price",
"buy_order_book.buy_fifth_price"
]
sellPricePaths = [
"sell_order_book.sell_first_price",
"sell_order_book.sell_second_price",
"sell_order_book.sell_third_price",
"sell_order_book.sell_fourth_price",
"sell_order_book.sell_fifth_price"
]
depthPaths = ("stock_code", buyPricePaths, sellPricePaths)
depthSchema = table(
["stockCode", "buyPrice", "sellPrice"] as name,
["STRING", "DOUBLE[]", "DOUBLE[]"] as type,
depthPaths as path
)
parseJsonTable(json=depthJson, schema=depthSchema)
| stockCode | buyPrice | sellPrice |
|---|---|---|
|
IF2403 |
[3598.8, NULL, 3598.4, 3598.2, 3598.0] |
[3599.0, 3599.2, 3599.4, 3599.6, 3599.8] |
Example 9: Read array elements and nested keys containing dots.
orderJson = '{"orderId":"A001","items":[{"price":10.5},{"price":12.0}],"data.id":{"child.value":3}}'
orderSchema = table(
["orderId", "firstPrice", "nestedValue"] as name,
["STRING", "DOUBLE", "INT"] as type,
["orderId", "items[0].price", '["data.id"]["child.value"]'] as path
)
parseJsonTable(json=orderJson, schema=orderSchema)
| orderId | firstPrice | nestedValue |
|---|---|---|
|
A001 |
10.5 |
3 |
Example 10: Handle a missing field, JSON null, a type conversion failure, and an array index out of range. Blank table cells indicate NULL.
statusJson = '{"orderId":"A001","data":{"price":null,"quantity":"unknown"},"items":[{"price":10.5}]}'
statusSchema = table(
["orderId", "missingPrice", "nullPrice", "invalidQuantity", "outOfRangePrice"] as name,
["STRING", "DOUBLE", "DOUBLE", "DOUBLE", "DOUBLE"] as type,
["orderId", "data.missingPrice", "data.price", "data.quantity", "items[1].price"] as path
)
parseJsonTable(json=statusJson, schema=statusSchema)
| orderId | missingPrice | nullPrice | invalidQuantity | outOfRangePrice |
|---|---|---|---|---|
|
A001 |
