json - 如何在 neo4j 中加载嵌套的 JSON
问题描述
我有一个 JSON 具有遵循模式的嵌套属性。这是一个简单的示例,其中显示了“envolves_to”如何嵌套和嵌套
{
species: {
name: 'sample name',
types: [
{name, id, and another static data}
]
},
evolves_to: [
{
species: [...],
evolves_to: [...another childs]
},
{
species: [...],
evolves_to: [] // this is empty, so this branch ends here
},
...anthoer siblings
]
}
这是我尝试使用的代码,但最终出现重复代码:
// get parent and childs
unwind value.evo_chain as evo_chain
with evo_chain.species as parent, evo_chain.evolves_to as childs
// create parent and types
create (p:Pokemon {name: parent.name})
with parent, p, childs
unwind parent.types as types
create (p)<-[:TYPE_OF]-(:Pokemon {
id: types.id,
name: types.name,
height: types.height,
weight: types.weight
})
// childs new parents
with childs as contents, p as superParent
with distinct contents, superParent
// repeat pattern
unwind contents as evo_chain
with evo_chain.species as parent, evo_chain.evolves_to as childs, superParent
create (superParent)<-[:CHILD_OF]-(p:Pokemon {name: parent.name})
with parent, p
unwind parent.types as types
create (p)<-[:TYPE_OF]-(:Pokemon {
id: types.id,
name: types.name,
height: types.height,
weight: types.weight
})
如何递归地重复搜索并开始创建关系和节点?
解决方案
推荐阅读
- ios - JOSESwift jwe 加密未能在 nimbus 服务器中解码
- axios - Nuxt 使用 JSON 服务器生成静态网站
- docker - Docker 不强制执行 apparmor 配置文件
- python - tf-idf sickitlearn 将“单词”与单词分开
- azure - Azure 订阅事件未能创建资源组“未定义”
- google-cloud-platform - 为什么 RDP 选项在 Windows VM 的 GCP 控制台中不可见?
- string - 通过使用折叠函数在它们之间放置分隔符将列表中的字符串连接成单个字符串(无递归)
- json - jq使用相同对象的值进行比较
- javascript - 淘汰赛组件更新可观察的父模型,但随后又恢复到旧值
- node.js - 未满足的依赖nodejs 8