I have attached a sample JSON text file. I am trying to pull modelYear and the LicensePlateNumber from the JSON. Can anybody provide a workflow on how to pull that information?
json.txt (1.4 KB)
Hi,
In short, your json is a JObject with some JArrays.
// JObject
{
"responseRecords": [ // JArray
{
...
"vehicles": [ // JArray
{
...
"modelYear": "1986",
...
"licensePlateNumber": "87096ST"
...
}
]
}
]
}
If you want get the modelYear and licensePlateNumber for the first vehicle (by your sample) you need assign:
firstVehicle = jsonObj("responseRecords")(0)("vehicles")(0)
The firstVehicle variable is a JToken, now you can get what you need by assigning:
movelYear = firstVehicle("modelYear")
firstVehicle = firstVehicle("licensePlateNumber")
Please note that here we are considering that you have only one responseRecords and only one vehicles. If you can have more items, consider use a For Each.
Thank you I will try it out and let you know how it works.
Would I use the assign activity after the Deserialize JSON activity and then a message box to see if it pulled the correct information?
Exactly, use the variable that you defined in the output of Deserialize JSON, replace the “jsonObj” sample that I wrote for that.
I changed it to jtoken. my message box it showing all the information though.
Alexandretpered,
Thank you for the help on this, Nice Work!
Any idea how I would assign the the pulled modelyear and licensePlate to its own variable? If I wanted to add those values to a excel sheet. We used a message box to show the model year of the vehicle, how would I store that year in a variable. I will eventually be needing to store multiple modelyears in a variable and then writing them to excel. Any Ideas?
I think I got the above figured out, I just used an assign activity to collect them into a variable
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.