DEV Community

Judy
Judy

Posted on

SQL, parse json data #eg28

In Google BigQuery database, data table stores a number of multilayer JSON strings. Below is one of them:

[{"active":true,"key":"key1","values":[{"active":true,"value":"value1"}]},{"active":true,"key":"key2","values":[{"active":true,"value":"value2"}]}]
Enter fullscreen mode Exit fullscreen mode

We need to parse the JSON strings and get all values under values.values field. Take the above JSON string as an example, the expected result is value1,value2.

Write the following SPL code:
Image description
A1: Run the simple SQL statement to retrieve JSON strings.

A2: Parse the multilayer strings and get all values of values.value.

Source

SPL open source address

Top comments (0)