javascript - Access elements in JSON after ajax request -
i have spent last couple of hours trying figure out this. make ajax request using jquery. response in string format , use
jquery.parsejson(response); to convert object. response:
{ "columns": ["n"], "data": [ [{ "extensions": {}, "labels": "http://localhost:7474/db/data/node/168/labels", "outgoing_relationships": "http://localhost:7474/db/data/node/168/relationships/out", "traverse": "http://localhost:7474/db/data/node/168/traverse/{returntype}", "all_typed_relationships": "http://localhost:7474/db/data/node/168/relationships/all/{-list|&|types}", "property": "http://localhost:7474/db/data/node/168/properties/{key}", "self": "http://localhost:7474/db/data/node/168", "properties": "http://localhost:7474/db/data/node/168/properties", "outgoing_typed_relationships": "http://localhost:7474/db/data/node/168/relationships/out/{-list|&|types}", "incoming_relationships": "http://localhost:7474/db/data/node/168/relationships/in", "create_relationship": "http://localhost:7474/db/data/node/168/relationships", "paged_traverse": "http://localhost:7474/db/data/node/168/paged/traverse/{returntype}{?pagesize,leasetime}", "all_relationships": "http://localhost:7474/db/data/node/168/relationships/all", "incoming_typed_relationships": "http://localhost:7474/db/data/node/168/relationships/in/{-list|&|types}", "metadata": { "id": 168, "labels": [] }, "data": { "name": "1" } }] ] } i try access specific elemets of object nothing back. when try
var test = json.data; it works how can access values saved in metadata. try "undefined":
var test = json.data.metadata.id; any idea missing?
it array, you've use index
var test = json.data[0][0].metadata.id; json.data[0] returns [{...}] , again [{...}][0] returns {...} has metadata object, in turn id property need.
Comments
Post a Comment