Iterating through nested json
Iterating through nested json
Hi there,
I was wondering if someone could help me with this.
I am trying to utilise values within the "Client" aspect of the Json below.
I can access this using {"data": "Client[0].Name"}, however there could be multiple items within this list which I want to unpack into the cell. So ideally I'd have each name separated by a comma. As the amount of items is variable, I can't use "Client[0].Name", "Client[1].Name" etc.
I have tried Client.Name and Client..Name but neither of these seem to work.
Any ideas?
Thanks in advance for any help anyone can offer!
{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"id": 2,
"Company_Name": "Example",
"Website": "http://www.example.com",
"Client": [
{
"id": 1,
"Name": "Client",
"Account": 2
},
],
"tags": {}
},
This question has an accepted answers - jump to answer
Answers
Use
columns.render
to loop through the array of client names to build the comma separated list of names. Use a standard Javascript loop to iterate the list of objects. Something like this:I didn't test this so it might need adjustments to work.
Kevin
Worked straight away, thank you Kevin, I really appreciate it. Have a great day!