javascript - jquery value in json -
i have json returned ajax call
[ {message:"haha", type:"error"}, {message:"nice work", type:"success"}, {message:"closed.", type:"success"} ]
and need find out if of items of type error. know can loop through , figure out wonder if if there function tell me need know
prior parsing json, test string match.
var json = '[{"message":"haha","type":"error"},{"message":"nice work","type":"success"},{"message":"closed.","type":"success"}]' if( json.indexof('"type":"error"') > -1 ) { // there error somewhere }
if json little loose spaces around keys/values, use regular expression test instead.
Comments
Post a Comment