Updated on 2024-10-12 GMT+08:00

How Do I Assign Values to and Use Lists and Objects?

During flow orchestration, if a reply variable in the Robot Reply diagram element, a cache variable (attribute in the response) in other diagram elements, or a variable in a conditional expression needs to operate or use list or object data, you can use the following methods for value assignment and usage.

Methods

  • Value assignment: If a flow variable is of the list type, you can assign a value in ["1","2","3"] format. If a flow variable is of the object type, you can assign a value in {"keyA":"valueA","keyB":"valueB"} format. Each element in a list or object can be a list or object.
  • Usage
    • If a flow variable FLOW.arr1 is of the list type and the default value is ["1","2","3"], you can use the FLOW.arr1[0] expression to obtain the value "1" of the first element.

      If a flow variable FLOW.arr2 is of the list type and the default value is [[1,2], [3,4]], you can use the FLOW.arr2[1][0] expression to obtain the value 3 of the first element.

    • If a flow variable FLOW.obj1 is of the object type and the default value is {"keyA":"valueA","keyB":"valueB"}, you can use the FLOW.obj1["keyA"] or FLOW.obj1.keyA expression to obtain valueA.

      If a flow variable FLOW.obj2 is of the object type and the default value is {"keyA":"valueA","keyB":{"keyC":"valueC"}}, you can use the FLOW.obj2["keyB"]["keyC"] or FLOW.obj2.keyB.keyC expression to obtain valueC.

    List or object elements obtained using methods can be properly calculated with other variable values and operated using built-in functions.