dict()

Returns the map created by provided key-value pairs.

Syntax

dict(KEY, VALUE, [KEY, VALUE,] ...])
Required Parameter
KEY, VALUE, [KEY, VALUE,] ...]
Key and value in order.

Description

The key can only be a string, not null, and must not overlap with other keys. If you provide multiple keys, the value you provide later is assigned. You can provide any type as a value.

Also, if the key-value pairs do not match (when the number of parameters is odd), an error will occur.

A map is a data type used in Java, and it refers to a dictionary used in languages such as Python.

Usage

json "{}" | eval dict=dict() => {}

json "{}" | eval dict=dict("a", "aaa") => {"a":"aaa"}

json "{}" 
| eval dict=dict(
  "name", "John",
  "age", 30,
  "host", ip("1.2.3.4"),
  "hobby", array("music","movie","sports"),
  "birthday", date("19800101","yyyyMMdd"))
=> {"birthday":"1980-01-01 00:00:00+0900","name":"John","host":"/1.2.3.4","age":30,"hobby":["music","movie","sports"]}