docs-v2/content/influxdb/cloud/reference/flux/stdlib/experimental/json/parse.md

948 B

title description menu weight
json.parse() function The `json.parse()` function takes JSON data as bytes and returns a value.
influxdb_cloud_ref
name parent
json.parse JSON-exp
401

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