【发布时间】:2021-04-08 12:15:37
【问题描述】:
我有一组具有 wsDestAddress 键的 JSON 对象,那么如何遍历 JSON 对象或在现有 JSON 对象中疯狂搜索 wsDestAddress 键以查找键是否存在并返回 @ 987654323@或""?
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 键搜索。
【问题讨论】:
标签: javascript json angular typescript