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

php - Admin SDK -- get information about the group -

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

Python Error - TypeError: input expected at most 1 arguments, got 3 -