WebService & Deserialization

I am using the web service found here https://www.amdoren.com/weather-api/ to build a module that I can reference in the future. This is my first time using this kind of api in Ui Path. I got the web service working but am running into with the Json array (See below). The question I have is once I have the array how do I do a for each item in forecast?

{ “error” : 0, “error_message” : “-”, “forecast”:[
{“date”:“2016-11-04”, “avg_c”:17, “min_c”:12, “max_c”:22, “avg_f”:63, “min_f”:54, “max_f”:72, “summary”:“Light rain”, “icon”:“wi_color_drizzle.png”},
{“date”:“2016-11-05”, “avg_c”:17, “min_c”:15, “max_c”:22, “avg_f”:63, “min_f”:59, “max_f”:72, “summary”:“Sunny”, “icon”:“wi_color_sunny.png”},
{“date”:“2016-11-06”, “avg_c”:19, “min_c”:13, “max_c”:23, “avg_f”:66, “min_f”:55, “max_f”:73, “summary”:“Partly cloudy”, “icon”:“wi_color_partly_cloudy_day.png”},
{“date”:“2016-11-07”, “avg_c”:19, “min_c”:14, “max_c”:21, “avg_f”:66, “min_f”:57, “max_f”:70, “summary”:“Moderate or heavy rain”, “icon”:“wi_color_rain.png”},
{“date”:“2016-11-08”, “avg_c”:14, “min_c”:8, “max_c”:17, “avg_f”:57, “min_f”:46, “max_f”:63, “summary”:“Light rain”, “icon”:“wi_color_drizzle.png”} ]}

I can use the following to get the error message for example.


Using Deserialize JSON Array I put the following in however I am not sure what do do with it from here or if this is the next step in parsing out the array.


My final file for reference if anybody is trying to figure this one out! WebService&DeserializationExample.zip (4.6 KB)

Use for each activity @LeftBrainCo after deserializing JSON string and give the inumerable as JSONDeserialized.Root … JSONDeserialized is the output of the deserialize json activity…

Then you will get the data children as you mentioned above… by giving as item(“error_message”)

1 Like

Thank you @HareeshMR that did the trick. I have attached the final test automation below just in case anybody else is trying to figure this one out!

WebService&DeserializationExample.zip (4.6 KB)

1 Like

Thank you @LeftBrainCo for thinking about the mates in forum …

1 Like

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