cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Set a non escaped JSON into string variable

One of my API results is returning a JSON string that is non-escaped. I am trying to set the JSON value to a string and then load the data into Neo4J.

Getting below error:

Invalid input '"': expected 'n/N' or 's/S' (line 8, column 13 (offset: 100))
"			"a":"b' a""
WITH '
{
    "total": 31,
    "limit": 10,
    "offset": 0,
    "results": [
        {"a":"b' a"},
		{"a":"c"},
		{"a":"d"},
		{"a":"e"},
		{"a":"f"},
		{"a":"g"},
		{"a":"h"},
		{"a":"i"},
		{"a":"j"},
		{"a":"k"},
    ]
}
' as jsonString

with apoc.convert.fromJsonMap(jsonString) as value 
return value
1 REPLY 1

You can escape the ' with a \', but there is also an issue with a trailing , in the results part of the map.

WITH '
{
    "total": 31,
    "limit": 10,
    "offset": 0,
    "results": [
        {"a":"b\' a"},
		{"a":"c"},
		{"a":"d"},
		{"a":"e"},
		{"a":"f"},
		{"a":"g"},
		{"a":"h"},
		{"a":"i"},
		{"a":"j"},
		{"a":"k"}
    ]
}
' as jsonString

with apoc.convert.fromJsonMap(jsonString) as value 
return value