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

Popular posts from this blog

Javascript line number mapping -

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -