訪問JSON對象鍵我有以下的JSON對象:有空間
{ "id": "109",
"No. of interfaces": "4" }
以下行工作的優良:
alert(obj.id);
alert(obj["id"]);
但如果鍵有空格,則我不能例如訪問它們的值
alert(obj."No. of interfaces"); //Syntax error
alert(obj["No. of interfaces"]); //Return 'undefined'
如何訪問其鍵名有空格的值?它甚至有可能嗎?
你確定嗎? http://jsfiddle.net/hoedinie/StU38/ 它適用於我很好 – amaters 2012-04-25 07:44:15