docs-v2/content/influxdb/v2.0/reference/flux/stdlib/dict/get.md

1.1 KiB

title description menu weight
dict.get() function The `dict.get()` function returns the value of a specified key in a dictionary or a default value if the key does not exist.
influxdb_2_0_ref
name parent
dict.get Dictionary
301

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

{{< req "All paremeters are required" >}}

dict

Dictionary to return a value from.

Data type: Dictionary

key

Key to return from the dictionary.

Data type: String | Boolean | Integer | Uinteger | Float | Time | Bytes

default

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

Data type: String | Boolean | Integer | Uinteger | Float | Time | Bytes

Examples

import "dict"

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

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

// Returns foo