Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  GetJsonObjectProperty - working with array of objects

    Posted 05-18-2025 18:46

    I've been dabbling with JSON paths in architect, the part I become stuck at, and would appreciate some guidance is when I'm working with an array of objects.

    I can get that nested array of objects with GetJsonObjectProperty easy enough, but then getting an array from one of the fields withing that object array it all falls apart. 

    Take something easy like:

    {
      "name": "bob",
      "pets": [
        {
          "Type": "cat",
          "Name": "paws",
          "age": "4"
        },
        {
          "Type": "dog",
          "Name": "tails",
          "age": "5"
        }
      ]
    }

    The output I'm after is an array of pet names

    I can get the array of pets with something like GetJsonObjectProperty(Flow.MyPets, "pets") where Flow.MyPets is the above json object. 

    But then getting just an array of names seems to escape me. I can't just do GetJsonObjectProperty(Flow.petsArray, "Name") or Flow.petsArray.Name etc.

    I am missing something fundamental, and basic here, but my brain just isn't processing this, any guidance would be appreciated.


    #Architect

    ------------------------------
    Anton Vroon
    ------------------------------


  • 2.  RE: GetJsonObjectProperty - working with array of objects

    Posted 05-19-2025 08:30

    I typically do my testing with https://www.javainuse.com/jsonpath (disclaimer: neither Genesys nor I have anything to do with this site)

    Putting in your example I came up with a few ways to get an array of pet names:

    pets..Name

    pets[*].Name

    $..Name

    In my opinion the first two examples are easier to read and less likely to break if additional Name fields are added to the response.



    ------------------------------
    --Jason
    ------------------------------



  • 3.  RE: GetJsonObjectProperty - working with array of objects

    Posted 2 hours ago
    Edited by Jeff Stevens 2 hours ago

    I too seem to be missing something fundamental.

    Using @Jason Mathison's JSONPath syntax recommendation(s), Architect only seems to return NOT_SET values. Are there any working examples of actually using GetJsonObjectProperty that returns the selected values as a JSON array?

    Note: This resolves fine on the evaluation tool, just not in the flow. Is this an Architect limitation, resolving the pathing syntax, expecting only a single propertyName?



    ------------------------------
    Jeff Stevens
    ------------------------------



  • 4.  RE: GetJsonObjectProperty - working with array of objects

    Posted 2 hours ago

    As far as I'm aware JSON path is not fully supported in Architect - I had created an idea for it, but got marked as Will not Implement- https://genesyscloud.ideas.aha.io/ideas/SSAAOB-I-250 

    GetJsonObjectProperty works for getting an object fine, but just not for filtering

    So in my above example GetJsonObjectProperty(Flow.MyPets, "pets") does work returning an array object, which I could set to a Json collection variable, and then loop through the collection like I would any other collection. This is the method I've been using, start with a json collection iterate through it in a loop and build my new json collection variable with just the items I want.

    Annoying yes, and if anyone has a better method also keen to hear it. 



    ------------------------------
    Anton Vroon
    ------------------------------