我試圖通過字符串(鍵) 來訪問hello值我得到了未定義的值。我沒有想法讓它工作。通過字符串從JSON對象獲取特定值
var key = "a.b.c.0";
var test = {"a":{"b":{"c":["hello","world"]}}};
console.log(test[key]); // undefined
console.log(test["a.b.c.0"]); // undefined
console.log(test["a.b.c[0]"]); // undefined
console.log(test["a.b.c"]); // fail
console.log(test.a.b.c); // [ 'hello', 'world' ]
console.log(test.a.b.c[0]); // hello
tooting我自己的號角,但https://github.com/r3mus/objectkit – brandonscript