Documentation

dict.get() function

Flux 0.97.0+

The dict.get() function returns the value of a specified key in a dictionary or a default value if the key does not exist.

import "dict"

dict.get(
  dict: [1: "foo", 2: "bar"],
  key: 1,
  default: ""
)

Parameters

All paremeters are required

dict

Dictionary to return a value from.

key

Key to return from the dictionary.

default

Default value to return if the key does not exist in the dictionary. Must be the same type as values in the dictionary.

Examples

Return a property of a dictionary
import "dict"

d = [1: "foo", 2: "bar"]

dict.get(
  dict: d,
  key: 1,
  default: ""
)

// Returns foo

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.