JSON array processing
Posted: Wed Jan 11, 2023 7:11 am
I am trying to process a json array in a loop of a task
I have got the correct number of array elements and stuggling to retrieve each username
My json array looks like this - how do I get to the username so that I can set the value of a variable as I loop?
{
"usersToEndSessions": [
{
"Row ID": "fc5cb3f0-916d-11ed-a5df-01647197df94",
"Created": "2023-01-11T05:08:28.979Z",
"Updated": "2023-01-11T05:51:04.345Z",
"username": "john.steven"
},
{
"Row ID": "71b9bc90-915c-11ed-a4c8-ee77646f8fe3",
"Created": "2023-01-11T03:02:54.941Z",
"Updated": "2023-01-11T05:51:04.353Z",
"username": "sam.smith"
}
]
}
What I have tried so far:
Works: Set a variable local@usersToEndSessionsValue to {json:local@RESTRESPONSE.usersToEndSessions}
Does not work: Log Message {json:local@usersToEndSessionsValue[1].username}
I'd expect it to log a username but instead simply prints out the whole string
Could not find any robotask doc on json array processing in a loop - thanks for your help
I have got the correct number of array elements and stuggling to retrieve each username
My json array looks like this - how do I get to the username so that I can set the value of a variable as I loop?
{
"usersToEndSessions": [
{
"Row ID": "fc5cb3f0-916d-11ed-a5df-01647197df94",
"Created": "2023-01-11T05:08:28.979Z",
"Updated": "2023-01-11T05:51:04.345Z",
"username": "john.steven"
},
{
"Row ID": "71b9bc90-915c-11ed-a4c8-ee77646f8fe3",
"Created": "2023-01-11T03:02:54.941Z",
"Updated": "2023-01-11T05:51:04.353Z",
"username": "sam.smith"
}
]
}
What I have tried so far:
Works: Set a variable local@usersToEndSessionsValue to {json:local@RESTRESPONSE.usersToEndSessions}
Does not work: Log Message {json:local@usersToEndSessionsValue[1].username}
I'd expect it to log a username but instead simply prints out the whole string
Could not find any robotask doc on json array processing in a loop - thanks for your help