Hello everyone,
I have an issue creating a Map of JSON Objects. I want to be able to create an argument which will accept information of type
{“partnerNr1-partnerNr2-partnerNr3”:{“familyPartners”:[{“partnerNumber”:“partnerNr1”,“firstName”:“name1”,“lastName”:“lastname1”,“dateOfBirth”:[year,month,day]},{“partnerNumber”:“partnerNr2”,“firstName”:“name2”,“lastName”:“lastname2”,“dateOfBirth”:[year,month,day]},{“partnerNumber”:“partnerNr3”,“firstName”:“name3”,“lastName”:“lastname3”,“dateOfBirth”:[year,month,day]}]}}
and from this info to seperate everything and print out the familyPartners each seperately in different rows:
name1 lastname1, dd.MM.yyyy
name2 lastname2, dd.MM.yyyy
name3 lastname3, dd.MM.yyyy
Anil_G
(Anil Gorthi)
May 5, 2023, 1:16pm
2
@Dea_Pahumi
You can download UiPath.webapi.activities and use desirialize json to convert your string to json
Then from json we can get the data usingb key value pair and for jarray we can use index
Eg: jobj("partnerNr1-partnerNr2-partnerNr3")("familyPartners")(0)("firstName").Tostring
would give you name1
Cheers
The value which I am sending is a Map not a String, so I can’t work with Deserialize JSON. My question is does UiPath even accept argument type Map?
Anil_G
(Anil Gorthi)
May 5, 2023, 1:51pm
4
@Dea_Pahumi
Are you talking about this?
cheers
I am looking for something like a Map (or HashMap) in Java, under System.Collections.Generic there is no such thing so I am not sure if this is what I actually need since its under DocumentFormat.OpenXml.Spreadsheet, I will take a look.
Anil_G
(Anil Gorthi)
May 6, 2023, 2:25pm
6
@Dea_Pahumi
Hashmap in java is similar to dictionary or a json data…
C sharp or vb do not have that type…
Its equivalents are to be used
Cheers
thanks for clearing that up, I will give it a try using Dictionary.
1 Like
Again I am stuck with this issue, when I try to set the dictionary like this
{{“1111-2222-3333”,“name1 lastname1, dob-name2 lastname2, dob-name3 lastname3, dob”}}
I get an error value of type 2-dimensional array of string cannot be converted to dictionary(String, String)
Anil_G
(Anil Gorthi)
May 9, 2023, 3:29pm
9
@Dea_Pahumi
Dictionary cannot be initialized like this
Use assign with dict("Key") = value
Cheers
If the value is being sent from Orchestrator I cannot initialize it like this, the value would need to be sent in another way and the bot needs to get the values based on the keys. I am not the one inserting the values into the Dictionary unfortunately
So there is no way that the bot receives a value like the ones provided above and then just for it to split it into keys and values itself?
Anil_G
(Anil Gorthi)
May 9, 2023, 4:29pm
11
@Dea_Pahumi
Can you structure it properly or let us know which one is key and value in it
M
Cheers
of course, the key would be “1111-2222-3333” and the value "“name1 lastname1, dob-name2 lastname2, dob-name3 lastname3, dob”
Anil_G
(Anil Gorthi)
May 11, 2023, 10:43am
13
@Dea_Pahumi
If its 2D array then
Dict(VarArray(0)(0)) = varArray(0)(1)
cheers
1 Like