Documentation

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.

import "experimental/json"

json.parse(
  data: bytes(v: "{\"a\":1,\"b\":2,\"c\":3}")
)

Parameters

data

JSON data to parse.

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,
            }
        },
    )

Was this page helpful?

Thank you for your feedback!


Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.