检索多层级对象是否包含有某字符串的key(value为同类思路)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="hello">
</head>
<body>
</body>
<script>
var cd={
"op" : "update",
"ns" : "db.nihaoTjbwVO",
"command" : {
"q" : {
"$or" : [{
"_RW_.rwbm.rwztbm" : "58",
"_RW_.rwbm.yssj" : {
"$lt" : "1604482920642"
}
}, {
"_RW_.rwbm.rwztbm" : "20",
"_RW_.rwbm.jssj" : {
"$lt" : "1604482800642"
}
}, {
"_RW_.rwbm.rwztbm" : "50",
"_RW_.rwbm.yssj" : {
"$lt" : "1604482920642"
}
}, {
"_RW_.rwbm.rwztbm" : "55",
"_RW_.rwbm.yssj" : {
"$lt" : "1604482920642"
}
}, {
"_RW_.rwbm.rwztbm" : "25"
}],
"lrrqLong" : {
"$gte" : "1604419200000",
"$lt" : "1604592000000"
}
},
"u" : {
"$set" : {
"_RW_.rwbm.rwztbm" : "10"
}
},
"multi" : true,
"upsert" : false
},
"user" : "cp@123"
};
function circleKey(commandObj){
if(typeof commandObj ==='object'){
for(var key in commandObj){
if((key+"").indexOf('rwbm')>-1){
return true;
}
if(typeof commandObj[key] !='object'){
if((key+"").indexOf('rwbm')>-1){
return true;
}
}else{
var rs=circleKey(commandObj[key]);
if(rs===true){
return true;
}
}
}
}
}
var result = circleKey(cd);
document.body.append(result);
</script>
</html>