How to read data from an Array contained in an object (Nested object data (objects))

How to read data from an Array contained in an object (Nested object data (objects))

ElnathElnath Posts: 2Questions: 1Answers: 0

I have implemented a table fed with JSON data.
The data structure is nested as in the example described on the page:
https://datatables.net/examples/ajax/deep.html

Write a procedure that retrieves data from the onclick event in a table row
data = table.row(this).data()

I retrieve data from objects without any problems. For example:

let start_date = data["hr"]["start_date"]

I have a problem getting data from Arrays objects. I tried different syntaxes, e.g.:

let contact_city = data["contact"][0]

where 0 means the first object in the array.

The console returns an error: Uncaught TypeError: Cannot read properties of undefined (reading '0')

I am sending some of the data returned from data = table.row(this).data()

Please help

This question has an accepted answers - jump to answer

Answers

Sign In or Register to comment.