从Json字符串中获取特定数据

时间:2015-02-04 08:31:49

标签: json

我从第三方服务器得到了这个json响应:

$jsonResponse = {"errors":[],"param_errors":[{"errors":[{"desc":"the email jb004@gmail.com is already registered by another account","code":"account_mail_is_used"}],"name":"account.mail"}],"code":"BAD_REQUEST","object":"error"}

我想只提取说明电子邮件已经注册的文字。你能帮忙吗?

1 个答案:

答案 0 :(得分:0)

$jsonResponse.paramErrors.forEach(function(paramError) {
    paramError.errors.forEach(function(error) {
         if(error.code==='account_mail_is_used')
         {
         // error found, do what u want with this error
            console.log(error.code, error.desc);
         }
    }
}
});