All Products
Search
Document Center

Simple Log Service:Dictionary functions

Last Updated:Jun 15, 2026

Dictionary functions allow you to create, update, delete, and query key-value pairs in dictionaries during data transformation.

Functions

Function

Description

dct_make

Builds a dictionary.

dct_update

Updates a dictionary.

dct_delete

Deletes a key-value pair from a dictionary.

dct_keys

Returns a list of dictionary keys.

dct_values

Returns a list of dictionary values.

dct_get

Returns the value of a specified key.

op_len

Returns the number of elements in a dictionary.

dct_make

Creates a dictionary.

  • Syntax

    dct_make(key1, value1, key2, value2, ...)
    Note

    You must specify keys and values in pairs.

  • Parameters

    Parameter Name

    Type

    Required

    Description

    key

    String

    Yes

    The dictionary key.

    value

    String

    Yes

    The value to associate with the key.

  • Response

    Returns the created dictionary.

  • Examples

    • Raw log

      content:test
    • Transformation rule

      e_set("hello", dct_make("k1","v1","k2","v2"))
    • Result

      content:test
      hello:{"k1": "v1", "k2": "v2"}

dct_update

Updates a dictionary.

  • Syntax

    dct_update(dict1, dict2)
  • Parameters

    Parameter name

    Type

    Required

    Description

    dict1

    dict

    Yes

    The dictionary to update.

    dict2

    dict

    Yes

    The dictionary to merge into dict1.

  • Response

    Returns the updated dictionary.

  • Examples

    • Raw log

      ctx: {"k1":"v1","k2":"v2"}
    • Transformation rule

      e_set("hello", dct_update(v("ctx"), {"k3": "v3"}))
    • Result

      ctx: {"k1":"v1","k2":"v2"}
      hello: {"k1": "v1", "k2": "v2", "k3": "v3"}

dct_delete

Deletes one or more key-value pairs from a dictionary.

  • Syntax

    dct_delete(dict, key1, key2, ...)
  • Parameters

    Parameter Name

    Parameter type

    Required

    Description

    dict

    dict

    Yes

    The dictionary from which to delete key-value pairs.

    key1

    String

    Yes

    The key of the key-value pair to delete.

    key2

    String

    No

    The key of the key-value pair to delete.

  • Response

    Returns the updated dictionary.

  • Examples

    • Raw log

      ctx: {"k1":"v1","k2":"v2"}
    • Transformation rule

      e_set("hello", dct_delete(v("ctx"), "k2"))
    • Result

      ctx: {"k1":"v1","k2":"v2"}
      hello: {"k1":"v1"}

dct_keys

Returns a list of all keys in a dictionary.

  • Syntax

    dct_keys(dict)
  • Parameters

    Parameter Name

    Parameter Type

    Required

    Description

    dict

    dict

    Yes

    The source dictionary.

  • Response

    Returns a list of the keys.

  • Examples

    • Raw log

      ctx: {"k1":"v1","k2":"v2"}
    • Transformation rule

      e_set("hello", dct_keys(v("ctx")))
    • Result

      ctx: {"k1":"v1","k2":"v2"}
      hello: ["k1","k2"]

dct_values

Returns a list of all values in a dictionary.

  • Syntax

    dct_values(dict)
  • Parameters

    Parameter Name

    Parameter type

    Required

    Description

    dict

    dict

    Yes

    The source dictionary.

  • Response

    Returns a list of the values.

  • Examples

    • Raw log

      ctx: {"k1":"v1","k2":"v2"}
    • Transformation rule

      e_set("hello", dct_values(v("ctx")))
    • Result

      ctx: {"k1":"v1","k2":"v2"}
      hello: ["v1","v2"]

dct_get

Returns the value of a specified key from a dictionary.

  • Syntax

    dct_get(dict,key,default=None)
  • Parameters

    Parameter Name

    Type

    Required

    Description

    dict

    dict

    Yes

    The dictionary to query.

    key

    String

    Yes

    The key whose value you want to get.

    default

    String

    No

    The value to return if the key does not exist.

  • Response

    Returns the value of the specified key.

  • Examples

    • Example 1

      • Raw log

        ctx: {"k1":"v1","k2":"v2"}
      • Transformation rule

        e_set("hello", dct_get(v("ctx"), "k1"))
      • Result

        ctx: {"k1":"v1","k2":"v2"}
        hello: v1
    • Example 2: If the key is not found, the default value is returned.

      • Raw log

        ctx: {"k1":"v1","k2":"v2"}
      • Transformation rule

        e_set("hello", dct_get(v("ctx"), "k3",default="123"))
      • Result

        ctx: {"k1":"v1","k2":"v2"}
        hello: 123