从 JSON 对象获取数据时出现问题

Issue with getting data from a JSON object

我收到来自 Ajax POST 请求的回复,如下所示:

{
    "columns": [
        "r"
    ],
    "data": [
        [
            {
                "extensions": {},
                "start": "http://localhost:7474/db/data/node/2762",
                "property": "http://localhost:7474/db/data/relationship/2709/properties/{key}",
                "self": "http://localhost:7474/db/data/relationship/2709",
                "properties": "http://localhost:7474/db/data/relationship/2709/properties",
                "type": "IS_CONNECTED_WITH",
                "end": "http://localhost:7474/db/data/node/2763",
                "metadata": {
                    "id": 2709,
                    "type": "IS_CONNECTED_WITH"
                },
                "data": {
                    "FOC_Type": "IRU",
                    "DuctType": "IRU",
                    "TrenchType": "IRU",
                    "linestringId": "53805"
                }
            }
        ]
    ]
}

以上是字符串。我要访问的是元素:"FOC_Type":"IRU""DuctType":"IRU""TrenchType":"IRU""linestringId":"53805".

我将字符串转换为 JSON,如下所示:

  var response = JSON.parse(response);

然后我尝试像这样访问一些值:

  var dataEquip = response[Object.keys(response)[Object.keys(response).length - 1]] // get the data from json obj

  var komvosName = dataEquip[0][2];

但我做不到。

我找到了一个解决方法,我不将响应转换为 JSON 格式,而是使用字符串。但这并不好。 如果有人能告诉我我做错了什么,我将不胜感激。

怎么样:

var responseJSON = JSON.parse(response);
var dataEquip = responseJSON ['data'] // get the data from json obj
var komvosName = dataEquip['TrenchType'];

一个JSON对象(responseJSON)只不过是一个关联数组。