How to push multiple variable values to an array of object key value?

For example

var firstname = "Mark:
var address = “USA”
var age = 24

Sample output would be :

{
  "firstname": "Mark",
  "address": "USA",
  "age": 24,
}

how do we do this in UIPath/vb . net ? Thank you.

I want to push to var values to as/to an array of objects.

Hi @AhmedKutraphali

You can use dictionary variable for this as it can store as key:value pairs as you have asked…thanks

1 Like

can you please provide an example @prasath_S just for referrence. Thanks.

Create a variable called dict datatype is system.collections.generic.dictionary(string,object)

In aasign give dict(“firstname”) = “Mark”

Likewise add all the value you want

And if you want to retrieve the value in message box put dict(“firstname”).tostring

Also please see this for reference

1 Like

@AhmedKutraphali
we can create a dictionary as by following:

dictData =

New Dictionary(Of String, Object) From {
  {"firstname","Mark"}, 
  {"address","USA"}, 
  {"age",24}
}

generating an output as expected is very close to a JSON serializing a dictionary
Newtonsoft.Json.JsonConvert.SerializeObject(dictData)
grafik

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.