parse-neo4j
Neo4j's http endpoint produces result that contains complete query information.
parse-neo4j
helps those who only want what they've returned in the query as normal JSON.
Install
npm install parse-neo4j --save
Usage
You can connect to neo4j's http endpoint via one of the many drivers available, e.g. official neo4j-driver
var neo4j = v1;var driver = neo4j;var session = driver;var result = session ;
Then you can parse the results:
var parser = ;var parsedResult = result ;
parser.parseRecord
could also be used for parsing a single record.
Example
Assuming below query:
MATCH (a:Label1)MATCH (a)-[:Another]->(b)RETURN a AS key1, b AS key2ORDER BY a.date DESCLIMIT 2
You get this output:
[ { "key1": { "field1": "...", "number": 42, "date": 1460183280000 }, "key2": {} }, { "key1": { "field1": "...", "number": 2, "date": 1460183280000 }, "key2": {} },]
As opposed to:
{ "records":[ { "keys":[ "key1", "key2" ], "length":2, "_fields":[ { "identity":{ "low":143258, "high":0 }, "labels":[ "Label1", "Label2" ], "properties":{ "field1":"...", "number":{ "low":42, "high":0 }, "date":1460183280000 } }, { "identity":{ "low":117186, "high":0 }, "labels":[ "Another", "Node" ], "properties":{} } ], "_fieldLookup":{ "key1":0, "key2":1 } }, { "keys":[ "key1", "key2" ], "length":2, "_fields":[ { "identity":{ "low":143260, "high":0 }, "labels":[ "Label1", "Label2" ], "properties":{ "field1":"...", "number":{ "low":2, "high":0 }, "date":1460183280000 } }, { "identity":{ "low":117186, "high":0 }, "labels":[ "Another", "Node" ], "properties":{} } ], "_fieldLookup":{ "key1":0, "key2":1 } } ], "summary":{ "statement":{ "text":"MATCH (a:Label1)\nMATCH (a)-[:Another]->(b)\nRETURN a AS key1, b AS key2\nORDER BY a.date DESC\nLIMIT 2", "parameters":{ "skip":{ "low":10, "high":0 }, "limit":{ "low":2, "high":0 } } }, "statementType":"r", "updateStatistics":{ "_stats":{ "nodesCreated":0, "nodesDeleted":0, "relationshipsCreated":0, "relationshipsDeleted":0, "propertiesSet":0, "labelsAdded":0, "labelsRemoved":0, "indexesAdded":0, "indexesRemoved":0, "constraintsAdded":0, "constraintsRemoved":0 } }, "plan":false, "profile":false, "notifications":[ ] }}