I struggle with this too. Imagine the case where you have multiple home phones, and you specifically want just home phone numbers. How do you do this? I ended up just updating my data action to return arrays instead. But would really like to learn and figure this out too, currently it feels like dealing with Arrays in Json is harder than it should be. But might just be a learning thing.
The best I have thought through (not tested out yet) is Creating a Collection JSON object of phoneNumbers and then using a loop to iterate through and pulling out the numbers. Using the find FindJsonArrayItem to get the index if looking for specific type.
But feel like there has to be an easier way.
If you figure it out please share.
------------------------------
Anton Vroon
------------------------------
Original Message:
Sent: 09-17-2024 05:07
From: Sai Kumar
Subject: Facing error while parsing JSON in Architect
Hello Genesys Cloud Community,
I am currently working with a JSON object (assigned to a variable Task.myJson) in Genesys Cloud Architect and have successfully parsed individual fields like "name." However, I'm encountering difficulties when trying to extract a collection of phone numbers from the following JSON structure:
{
"name": "John Doe",
"phoneNumbers": [
{
"type": "home",
"number": "555-555-5555"
},
{
"type": "work",
"number": "555-555-1234"
}
],
"hobbies": ["reading", "hiking", "coding"]
}
While I'm able to parse the "name" field, I'm getting error while parsing array of phone numbers. Any guidance or suggestions on how to achieve this in Architect would be greatly appreciated.
I need to extract the phone numbers in the following format:
[
"555-555-5555",
"555-555-1234"
]
#Routing(ACD/IVR)
#Unsure/Other
------------------------------
Sai Kumar
Cognizant Technology Solutions India Private Limited
------------------------------