I have problem with get string in JSON data. Format as below:
[
{ "name": "Alice", "age": "20" },
{ "id": "David", "last": "25" },
{ "id": "John", "last": "30" }
]
Sometime it changes position together, John from 3rd place go to 2nd place:
[
{ "name": "Alice", "age": "20" },
{ "name": "John", "age": "30" },
{ "name": "David", "age": "25"}
]
If i use data[3].age to get John's age, and data change position, I will get David's age.
Is there any method I can use to find the object with name David and get the age value?
data[3].agewill give you an index error.