Multiple API output writing to excel

Hy everybody

I’m a newbie on here, setting my first steps.

I have two questions:

I have an API Response (GET call):

{
“cargo”:[
{
“customer”:{
“code”:“0001”,
“name”:“XXXXX”
},
“date”:“20N0/01/01”,
“container”:[
{
“containerPart”:1,
“vehicle”:{
“vehiclePlate”:“7AAA1130”,
“trailerPlate”:“7AAA1240”,
“driverName”:“XXX”
}
}
]
},

{
“customer”:{
“code”:“0002”,
“name”:“XXXXX”
},
“date”:“20N0/01/01”,
“container”:[
{
“containerPart”:1,
“vehicle”:{
“vehiclePlate”:“7AAA1123”,
“trailerPlate”:“7AAA1234”,
“driverName”:“XXX”
}
}
]
}
]
}

So I would like to go through the entire response and I want to retrieve for each customer code the drivername that is driving.

Other than that i just want to retrieve all the dates (“date”)and place them in Excel.

So i get how you would make an excel datatable from this but i do not entirely understand how to go through the entire response and split the different ‘cargo’s’ from each other.

Any idea’s?

Thanks in advance

You would want to use the “Deserialize JSON” Activity To Turn that string into a JObject. Then you could use a for each loop to iterate through each JRow in the Jobject. I’ll find a sample activity for you to check out in a sec.

Sauce- Extract data from http response - #7 by Mr_Meeseeks

The Documentation is really nice for this activity. There is a sample XAML file in there for you- https://docs.uipath.com/activities/docs/deserialize-json

Hy Mr_Meeseeks

Thanks for the help. I understand the deserialisation.

But afterwards it fails with me. The iterasation doesn’t work. Or I get an “Accessed JArray values with invalid key value: “driverName”. Int32 array index expected.” error