1.1 KiB
1.1 KiB
| title | description | aliases | menu | weight | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| json.encode() function | The `json.encode()` function converts a value into JSON bytes. |
|
|
202 |
The json.encode() function converts a value into JSON bytes.
Function type: Type conversion
import "json"
json.encode(v: "some value")
This function encodes Flux types as follows:
timevalues in RFC3339 formatdurationvalues in number of milliseconds since the epochregexpvalues as their string representationbytesvalues as base64-encoded stringsfunctionvalues are not encoded and produce an error
Parameters
v
The value to convert.
Data type: Boolean | Duration | Float | Integer | String | Time | UInteger
Examples
Encode all values in a column in JSON bytes
import "json"
from(bucket: "example-bucket")
|> range(start: -1h)
|> map(fn: (r) => ({
r with _value: json.encode(v: r._value)
}))