Documentation

json.encode() function

Flux 0.40.0+

The json.encode() function converts a value into JSON bytes.

import "json"

json.encode(v: "some value")
// Returns [34 115 111 109 101 32 118 97 108 117 101 34]

This function encodes Flux types as follows:

  • time values in RFC3339 format
  • duration values in number of milliseconds since the epoch
  • regexp values as their string representation
  • bytes values as base64-encoded strings
  • function values are not encoded and produce an error

Parameters

v

The value to convert.


Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.