I have a response from an Ajax POST request which looks like this:
{
"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"
}
}
]
]
}
The above is a string. What I am trying to access is the elements: "FOC_Type":"IRU"
,"DuctType":"IRU"
,"TrenchType":"IRU"
,"linestringId":"53805"
.
I transform the string to JSON like this:
var response = JSON.parse(response);
and then I try to access some of the values like this:
var dataEquip = response[Object.keys(response)[Object.keys(response).length - 1]] // get the data from json obj
var komvosName = dataEquip[0][2];
But I can not make it work.
I found a work around in which I don't convert the response to JSON format and I play with the string. But that's not nice. I would appreciate if someone could show me what I do wrong.