Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-21-2020 10:33 AM
I am trying to connect neo4j with DesiteMd through javascrift. But in neo4j i am getting the following message ''WARN /db/data/cypher org.codehaus.jackson.JsonParseException: Unexpected character ('o' (code 111)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at [Source: java.io.StringReader@3eb74e5; line: 1, column: 3]' The javascrift which I am using is
function myFunction5() {
var x = desiteAPI.getSelected();
console.log(x);
document.getElementById("demo").innerHTML = String(x);
var myJSON = JSON.stringify ("x");
var MatchQuery = new XMLHttpRequest();
MatchQuery.open('POST', 'http://localhost:7474/db/data/cypher ', true);
MatchQuery.setRequestHeader("Content-type", "application/json;charset=utf-8");//"Basic " + btoa("neo4j:123")
var y = {"query" : "MATCH(a:" + String(x) + "), (b:Tasks) MERGE(a)-[r:relation]-(b) Return a,b"};
console.log(y)
MatchQuery.addEventListener('load', function (event) {
if (MatchQuery.status >= 200 && MatchQuery.status < 300) {
console.log(MatchQuery.responseText);
} else {
console.warn("error");
console.warn(MatchQuery.statusText, MatchQuery.responseText);
}
});
}`
Could somebody guide me kindly? Thank you
01-22-2020 04:35 AM
There are several things in this code you need to check and possibly fix.
JSON.stringify("x")
probably doesn't do what you intend - that will just return the string "x" because you're passing it a literal and not a variable. I'm not even sure you're using myJSON"MATCH(a:" + String(x) + ")
I'm not sure the right thing is happening there either, and I can't see the value of the variable X. So the root cause is probably that you're constructing an invalid JSON object in 'y'.Make sure that 'y' is valid JSON first.
All the sessions of the conference are now available online