舉例來說,如果我有Typescript:有沒有一種方法可以獲得嵌套屬性的JavaScript對象中的所有鍵?
{
"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"
是。可能的重複http://stackoverflow.com/questions/2549320/looping-through-an-object-tree-recursively – hackerrdave
[循環通過對象(樹)遞歸]的可能重複(http://stackoverflow.com/questions/2549320 /循環通過對象樹遞歸) – nicovank
有這個解決方案的一些問題http://stackoverflow.com/questions/41929287/typescript-what-could-be-causing-this-error-element-隱含地有任何t – icda