Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/444.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
包含键值对javascript的数组_Javascript_Json_Rally - Fatal编程技术网

包含键值对javascript的数组

包含键值对javascript的数组,javascript,json,rally,Javascript,Json,Rally,所以我有一个故事阵列: story[0]=[{"_ref":"/hierarchicalrequirement/15475417305","FormattedID":"US79832","Owner":"A","EstCP":0}] story[1]=[{"_ref":"/hierarchicalrequirement/15790056238","FormattedID":"US81776","Owner":"B","EstCP":0}] story[2]=[{"_ref":"/hiera

所以我有一个故事阵列:

 story[0]=[{"_ref":"/hierarchicalrequirement/15475417305","FormattedID":"US79832","Owner":"A","EstCP":0}]
 story[1]=[{"_ref":"/hierarchicalrequirement/15790056238","FormattedID":"US81776","Owner":"B","EstCP":0}]
 story[2]=[{"_ref":"/hierarchicalrequirement/15790059145","FormattedID":"US81777","Owner":"C","EstCP":7.5}]
如何获取story[2]的FormattedID密钥?我试过:

1. story[2].get("FormattedID")
2. story[2].FormattedID
3. story[2]["FormattedID"]
4. story[2][FormattedID]
5. story[2].getCollection("FormattedID")
6. story[2].get(FormattedID)
这些都不管用。任何帮助都将不胜感激。谢谢。

故事[2]是一个只有一个条目的数组。您可以通过[0]访问该条目。该对象具有属性,因此:

story[2][0].FormattedID
…给你价值

使用一些换行符可能会更清楚。以下是您分配给故事[2]的内容:


…具有FormattedID属性。您可以使用点表示法和文字属性名称.FormattedID,或使用括号表示法和字符串属性名称[FormattedID]来访问它。

在创建故事对象时,请删除括号。然后你就可以按你的期望去做了

例如:

 story[0]={"_ref":"/hierarchicalrequirement/15475417305","FormattedID":"US79832","Owner":"A","EstCP":0}

story[0].FormattedID

用括号实际上是在创建一个数组,在主数组的每个点上都有一个项目。

story[2][0][FormattedID];可能是重复的哦,我明白了,每个故事都是一个独立的数组。很抱歉错过了。谢谢Rick,这是我看到的预定义数组的表示。我没有这样定义它。
{
    "_ref": "/hierarchicalrequirement/15790059145",
    "FormattedID": "US81777",
    "Owner": "C",
    "EstCP": 7.5
}
 story[0]={"_ref":"/hierarchicalrequirement/15475417305","FormattedID":"US79832","Owner":"A","EstCP":0}

story[0].FormattedID