I need to get an item from the json output however the json contents aren't always consistent.
For example if I wanted get the value for "name" it would be ['result']['attributes'][0]['name'];
But in the event that the json is delivered as the second example it would be ['result']['attributes'][1]['name'];
{"result":{
"attributes":[
{"user":"newb","name":"mike"},
{"state":"california","city":"los angeles"}
]
}}
{"result":{
"attributes":[
{"state":"california","city":"los angeles"},
{"user":"newb","name":"mike"}
]
}}
How would I get the "name" value if the index of the array it's in is unknown?
attributesproperty is not designed very well; instead of an array of bizarrely-grouped attributes, it should just be an object with each attribute declared separately. i.e.:{"result":{"attributes":{"user":"newb","name":"mike","state":"california","city":"los angeles"}}}