I am using PHP json_encode() to generate JSON data of a shopping cart:
{
"6cb380f1bfbcd7728be7dfbf2be6bad4": {
"rowid": "6cb380f1bfbcd7728be7dfbf2be6bad4",
"id": "sku_131ABC",
"qty": "4",
"price": "35.95",
"name": "T-Shirt",
"options": {
"Size": "M",
"Color": "Red"
},
"subtotal": 143.8
}
}
As you notice the initial ID is unique and not predictable. Is there a way in JavaScript
where I can use this data? I am trying to get the values of qty, price(etc).
I was thinking if something on the lines of an index reference exists.
Thedata[0].name
I know this doesn’t work, but is something like this possible?
This will work for you: