Legacy Dev Forum Posts

 View Only

Sign Up

Get particular object value out from JSON?

  • 1.  Get particular object value out from JSON?

    Posted 06-05-2025 19:15

    VaunMcCarthy | 2023-10-30 03:01:14 UTC | #1

    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


    MelissaBailey | 2023-10-30 16:21:55 UTC | #2

    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])

    VaunMcCarthy | 2023-10-30 19:11:53 UTC | #3

    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?


    MelissaBailey | 2023-10-30 19:33:04 UTC | #4

    If your json is

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

    then to get Chicago use

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


    system | 2023-11-30 19:33:51 UTC | #5

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


    This post was migrated from the old Developer Forum.

    ref: 22803