Hello Good Morning. I am trying to change the format of an Array of dictionaries to a List of dictionaries. Does anyone know the olgo formula to do it? Thank you very much!
Hey!
You convert the array to list. Follow the steps:
- Create a new list variable
- Take one assign activity and do this
newList = myArray.ToList
That’s it.
Reference:
Regards,
NaNi
To convert an array of dictionaries to a list of dictionaries in UiPath, you can use the following approach:
- Create a new List of Dictionaries variable: Define a new variable of type
List<Dictionary<string, object>>
to store the converted data. Let’s call itlistOfDictionaries
. - Initialize the List variable: Assign an empty list to the
listOfDictionaries
variable using the “Assign” activity. Set its initial value asNew List(Of Dictionary(Of String, Object))()
. - Loop through the Array of Dictionaries: Use a “For Each” activity to iterate over each element in the array. Let’s call the current element
dictionary
within the loop. - Add Dictionary to List: Inside the loop, use the “Add To Collection” activity to add the
dictionary
variable to thelistOfDictionaries
variable.a. Set the “Collection” property of the “Add To Collection” activity aslistOfDictionaries
.b. Set the “Item” property asdictionary
. - After the loop, the
listOfDictionaries
variable will contain the converted data in the desired format.
Thanks!!