【发布时间】:2017-06-15 04:18:39
【问题描述】:
例如,如果我有
{
"key1":{
"key2":[
{
"key3":[
{
"key4":{
"key5":0
}
},
{
"key6":{
"key7":""
}
}
]
},
{
"key8":{
"key9":true
}
}
]
}
}
有没有办法像这样得到所有的钥匙?
["key1", "key2", "key3", "key4", "key5", "key6", "key7", "key8", "key9"]
编辑:我在这里尝试了suggestion,但没有成功Typescript: what could be causing this error? "Element implicitly has an 'any' type because type 'Object' has no index signature"
【问题讨论】:
-
是的。 stackoverflow.com/questions/2549320/… 的可能重复项
标签: javascript recursion javascript-objects