我有一组具有wsDestAddress
密钥的 JSON 对象,那么如何遍历 JSON 对象或wsDestAddress
在现有 JSON 对象中疯狂搜索密钥以查找密钥是否存在并返回null
或""
?
JSON 对象 #1
{
"gfutd": {
"wsRequestData": {
"wsDestAddress": ""
}
}
}
JSON 对象 #2
{
"igftd": {
"wsRequestData": {
"wsDestAddress": ""
}
}
}
JSON 对象 #3
{
"y7igfutd": {
"wsResponseData": {
"wsDestAddress": ""
}
}
}
JSON 对象 #4
{
"y7igptdf": {
"wsRequestData": {
"returnAddress": {
"wsDestAddress": ""
}
}
}
}
我知道这段代码工作正常
if (y7igfutd.wsRequestData.wsDestAddress == "" ||
igftd.wsRequestData.wsDestAddress == "" ||
y7igfutd.wsResponseData.wsDestAddress == "" ||
y7igfutd.wsRequestData.returnAddress.wsDestAddress == "") {
return "result"
}
但我想做一个疯狂的搜索wsDestAddress
作为 JSON 键搜索。