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.

How to parse json and create nodes with foreach in Neo4j?

Sample json:

{
    "data": [
            {
                "file" : "1.txt",
                "type" : "text"
            },
            {
                "file" : "2.json",
                "type" : "json"
            },
            {
                "file" : "1.html",
                "type" : "html"
            }
    ]
}

I am trying to create 3 nodes with file and type as properties

I am using following query to create nodes in neo4j

WITH {json} AS document 
UNWIND document.data AS data
FOREACH (node in data| CREATE(m:`member`) SET m = node )

I am getting following error when i use py2neo driver:

AttributeError: 'module' object has no attribute 'SyntaxError'

1 REPLY 1

I think this should be the following:

WITH {json} AS document 
UNWIND document.data AS data
CREATE(m:`member`) SET m = data