Problem description: I want to use apoc.load.json
, however in a certain manner, namely instead of url or the file path use variable as argument. The reason for this is that I am sending my json as part of CURL, so I can capture it and save to variable, is there some workaround? For instance (unfortunately it doesn't work, as it requires some path and not a JSON object ):
var inputObject = req.body;
var jsonObject = JSON.stringify(inputObject);
.run('WITH $inputParam AS url CALL apoc.load.json(url) ...', {inputParam: jsonObject})
Probably there is some other way to retrieve the json data from curl and to process json in general, besides apoc.
The curl, if it will be helpful:
curl -s -H "Content-Type: application/json" -X POST -d'{"origin":[{"label":"Alcohol drinks", "tag":[], "type":"string", "xpath":[]}, {"label":"Wine", "tag":["red","white"], "type":"string", "xpath":["Alcohol drinks"]}, {"label":"Port wine", "tag":["Portugal","sweet","strong"], "type":"string", "xpath":["Alcohol drinks","Wine"]}, {"label":"Sandeman Cask 33", "tag":["red","expensive"], "type":"string", "xpath":["Alcohol drinks","Wine","Port wine"]}], "target":[{"label":"Drinks", "tag":[], "type":"string", "xpath":[]}, {"label":"Tea", "tag":["black", "green"], "type":"string", "xpath":["Drinks"]}, {"label":"Carbonated water", "tag":[], "type":"string", "xpath":["Drinks","Tea"]}, {"label":"Pepsi", "tag":["sweet","cheap"], "type":"string", "xpath":["Drinks","Tea","Carbonated water"]}]}' http://localhost:3000/ontology
I will appreciate any help. Thank you in advance.
P.S. I also published the same issue on Stackoverflow, link:
https://stackoverflow.com/questions/54892614/apoc-import-extract-json-from-curl