json.parse() function
The json.parse()
function is experimental and subject to change at any time. By using this function, you accept the risks of experimental functions.
The json.parse()
function takes JSON data as bytes and returns a value. The function can return lists, records, strings, booleans, and float values. All numeric values are returned as floats.
*Function type: Type conversion*
import "experimental/json"
json.parse(
data: bytes(v: "{\"a\":1,\"b\":2,\"c\":3}")
)
Parameters
data
JSON data to parse.
*Data type: Bytes*
Examples
Parse and use JSON data to restructure a table
import "experimental/json"
data
|> map(fn: (r) => {
jsonData = json.parse(data: bytes(v: r._value))
return {
_time: r._time,
_field: r._field,
a: jsonData.a,
b: jsonData.b,
c: jsonData.c,
}
})