json.encode() function

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



The value to convert.

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.