Parse arrays of json data

Hello everyone,

I am trying to figure how to parse a json response that contains 2 arrays of data. It contains the data as follow:

{ “tasks” : “task1, task2, task3”, “taskdetails” : “details1, details2, details3” }

I need to put these into two separate lists to use to build a list item.

Any help would be greatly appreciated.

Thanks

For simplification i would suggest you to use JSON Tool by Luke Gackle (JSONTools Extension), as I feel more comfort with this. If you want to parse this json with json tool just let me know.

Hi,
Try to do it without using the make a list block. Just set taskt list to look up in pair block without the make a list block

@plantdoc2018
I have downloaded the extension.
Any help you could provide would be great!

Thanks

Import it on your project screen where u want to parse the json. Then on block section you might find a block named “parse json”. Set the block with “response content”. It means if the response content (text) is in json format it will parse it systematically. Then if the array has a specific name use “open json array” block with the name. Then as I can see your json is simple list you can use “for each number” block where you can use “get string value” block. Now every string has its name in the list with a specific index. Use it where you want to print. Simple.

If still feeling complicated send me the aia i can arrange the block for you if you want.

Thanks for the help.

My json structure has been updated now, as the extension threw an error stating the original was not valid json.

Example of current structure is:

{
“response”: {
“tasks” : [
{
“title”: “test”,
“subtitle”: “testsubtitle”
},
{
“title”: “test”,
“subtitle”: “testsubtitle”
}
]
}
}

Any help on how I can get the data for each index in the “tasks” array? Eg. Title and Subtitle of each item.

Thanks again!

Read my previous msg again. All answers are there. Just put the “OpenJsonArray” block outside the for each loop as this tool can’t do any activity like opening any array or object within “ForEachLoop” block.