Documentation

dict.fromList() function

The dict.fromList() function creates a dictionary from a list of records with key and value properties.

import "dict"

dict.fromList(
  pairs: [
    {key: 1, value: "foo"},
    {key: 2, value: "bar"}
  ]
)

Parameters

pairs

(Required) List of records, each containing key and value properties.

Data type: Array of records

Examples

Create a dictionary from a list of records
import "dict"

// Define a new dictionary using an array of records
d = dict.fromList(
  pairs: [
    {key: 1, value: "foo"},
    {key: 2, value: "bar"}
  ]
)

// Return a property of the dictionary
dict.get(dict: d, key: 1, default: "")

// Returns foo

New! Cloud or OSS?

InfluxDB OSS 2.0 now generally available!

InfluxDB OSS 2.0 is now generally available and ready for production use. See the InfluxDB OSS 2.0 release notes.

For information about upgrading to InfluxDB OSS 2.0, see: