Get particular object value out from JSON?

Could someone please paste for me an example of what function(s) I"d use in Architect if I have a JSON body, something like:

{"name":"John",
"towns":["Chicago"])

Say I want to get the values of both name and towns and put those into string variables. While the towns shows as an array there'd normally only ever be one value there.

Thanks

Vaun

Where Task.json is your json object, to get the name

ToString(GetJsonObjectProperty(Task.json, "name"))

To get the 1st town in the list

ToString(GetJsonObjectProperty(Task.json, "towns")[0])

Thanks a lot Melissa, I'll try that later but that does look like exactly what I need. How would it be modified if there was a nested object? Say country.towns?

If your json is

{	"name":"John",
	"location": {
	    "town":"Chicago",
  	    "state":"IL"
	}
}

then to get Chicago use

ToString(GetJsonObjectProperty(GetJsonObjectProperty(Task.json, "location"), "town"))

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