jquery验证json里某个数据是否存在
json格式[{"name":"哈哈··","email":["123@qq.com","4545@163.com"]},{"name":"呵呵··","email":[...
json格式
[
{
"name": "哈哈··",
"email": [
"123@qq.com",
"4545@163.com"
]
}, {
"name": "呵呵··",
"email": [
"fa@fed.cm",
"fff@gmail.com"
]
}
]
我要怎么验证4545@163.com是否存在
或者如何将上面的json转换为
var arr = ["123@qq.com","4545@163.com","fa@fed.cm","fff@gmail.com"]
这样的数组 展开
[
{
"name": "哈哈··",
"email": [
"123@qq.com",
"4545@163.com"
]
}, {
"name": "呵呵··",
"email": [
"fa@fed.cm",
"fff@gmail.com"
]
}
]
我要怎么验证4545@163.com是否存在
或者如何将上面的json转换为
var arr = ["123@qq.com","4545@163.com","fa@fed.cm","fff@gmail.com"]
这样的数组 展开
展开全部
var arr = [{
"name": "哈哈··",
"email": ["123@qq.com", "4545@163.com"]
}, {
"name": "呵呵··",
"email": ["fa@fed.cm", "fff@gmail.com"]
}];
var tmp = "4545@163.com";
for (var i = 0; i < arr.length; i++) {
var obj = arr[i];
if (obj.email.indexOf(tmp) != -1) {
alert("存在");
break;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询