如何在 Neo4j 中解析 json 并使用 foreach 创建节点?

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

样本json:

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

我正在尝试使用文件和类型创建 3 个节点作为属性

我正在使用以下查询在 neo4j 中创建节点

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

当我使用 py2neo 驱动程序时出现以下错误:

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

查询应该像 -

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

在你的情况下或者使用UNWIND或者FOREACH

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

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