The following RESTful JSON Interface is needed to submit a Query (e.g. Node creation) to a Neo4j-Database:
{ "statements" : [ { "statement" : "CREATE (n) RETURN id(n)" } ]}
The JSON-Object is created internal the WEBWRITE-Function. The nested structure can be created in Matlab and is compiled to JSON by the WEBWRITE-Function as well. I was unable to create a JSON List (Array) by using the following approach (Cell Array):
api = 'http://localhost:7474/';url = [api 'db/data/transaction/commit'];statem{1,1} = 1;ab = struct('statement', 'CREATE (n) RETURN id(n)');statem{1,1} = ab;statems = struct('statements', statem);options = weboptions('ContentType','json', 'MediaType','application/json', 'RequestMethod','POST', 'Username', 'neo4j', 'Password', 'test');data = webwrite(url, statems, options);
JSON-Result created by the function above:
{ "statements": { "statement": "CREATE (n) RETURN id(n)" }}
Is there a way to create a List in the JSON-Object created by WEBWRITE?
Best Answer