How to get json object by javascript item -


so have array of json objects these below. retrieved using xmlhttp. want 'select' value name == "test" using javascript how do this? know can example data[0] not how want because id can change.

[  {"name" : "test", "value": "something"}, {"name" : "test2", "value": "something else"}  ] 

you can use loops this, can use array.filter , can first match, ex.:

var items = [{"name" : "test", "value": "something"},{"name" : "test2", "value": "something else"}];    var = "name", = "test2"  , select = items.filter(function(item){ return item[where] == is})[0];    console.log(select)


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -