I'm trying to parse some nested json returned by an api call. Below is a simplified version of what is being returned.
{
"Includes":{
"Products":{
"P123456":{
"Brand":{},
"Description":"ipsem lorem",
"Statistics":
[
"Author":"John Smith",
"IsFeatured":false,
"Total": 3
]
}
}
}
}
I've tried several different syntaxes to get what I need where product_code = "P123456"
data.Includes.Products.product_code.Statistics
data.Includes.Products[product_code].Statistics
I've also tried using 'get' and 'eval' to no avail. The error response is always the same
application.js:1639 Uncaught TypeError: Cannot read property 'Statistics' of undefined
I know the product code is correct as I have console logged it. I have also successfully console.logged
data.Includes.Products["P123456"].Statistics
How can I access the data nested under the product code, "P123456" ? The project uses zepto and not jQuery.