javascript - how can i test if elements are in json data -
i need check if element in json data.
json data
{ "status": { "carts": [ { "service": "page-mailer", "running": "", "last success": "2015-05-07 09:35:31" } ], "pages": [ { "service": "page-mailer", "running": "", "last success": "2015-05-07 09:35:31" } ], "actions": [ { "service": "page-mailer", "running": "", "last success": "2015-05-07 09:35:31" } ], "integrations": [], "service": [ { "service": "page-mailer", "running": "", "last success": "2015-05-07 09:35:31" } ], "smtp": [ { "server": "myserver" } ], "servers": [] }, "timing": "2ms" }
something like,
if(carts){} if(pages){} etc
i using jquery getjson();
below should work you
if(data && data.status && data.status.carts){ console.log("exist") }
Comments
Post a Comment