Accessing Data from Json Object
Very new to using JSON and using these 2 data sets:
{
"myNames" [
{"name": "Name 1","index": 0},
{"name": "Name 2","index": 1}
]
}
{
"myDetails" [
{"name": "Name 1","story":This is 1's story"},
{"name": "Name 2","story":This is 2's story"}
]
}
var count = data.myNames.length; //valid and gives 2
var nam=data.myNames[1].name //gives Name 2
- It seems that the data is treated as an Array. I've seen where the JSON data is implicitly declared as an array, but this is not. Is there an advantage to this and would the data declared as an array still go into the Echo?
- I use the data from myNames for a list which is used to get the relevant data from myDetails. The data in myNames is sorted but the data in myDetails is not. In the list grid click JS I have:
codevar getname=$(this).text();/code
Is there a fast way to extract the relevant data in myDetails?