apoc 怎么取出 json 文件中的key 和value
发布于 6 年前 作者 bigocean 2685 次浏览 来自 问答

1, 我的json文件如下: {“e”:{“propertyList”:[{“value”:“北京”,“key”:“name”},{“value”:“marked_f”,“key”:“from”}],“id”:63415,“labels”:[“loc”]}} {“e”:{“propertyList”:[{“value”:“渤海”,“key”:“name”},{“value”:“marked_f”,“key”:“from”}],“id”:63416,“labels”:[“loc”]}} {“e”:{“propertyList”:[{“value”:“朝鲜半岛”,“key”:“name”},{“value”:“marked_f”,“key”:“from”}],“id”:63417,“labels”:[“loc”]}}

2,通过apoc 已经得到如下结果: WITH “file:///d://entities.txt” AS url CALL apoc.load.json(url) YIELD value UNWIND value.e AS item with item,item.propertyList as alist return item.id,alist "item.id"│"alist" │ ╞═════════╪══════════════════════════════════════════════════════════════════════╡ │63415 │[{“value”:“北京”,“key”:“name”},{“value”:“marked_f”,“key”:“from”}] │ ├─────────┼──────────────────────────────────────────────────────────────────────┤ │63416 │[{“value”:“渤海”,“key”:“name”},{“value”:“marked_f”,“key”:“from”}] │ ├─────────┼──────────────────────────────────────────────────────────────────────┤ │63417 │[{“value”:“朝鲜半岛”,“key”:“name”},{“value”:“marked_f”,“key”:“from”}] │

3, 我下一步用什么cypher或apoc命令把 key:“name”,value:"北京“; key:“from“,value:“marked_f” 取出来? 搞了3,4天了也没进展,求救!

2 回复

Java下利用Jackson进行JSON解析和序列化

WITH ‘file:///entities.json’ as url CALL apoc.load.json(url) YIELD value UNWIND value.e AS item with item,item.propertyList as alist unwind range(0,length(alist)-1) as x return item,alist,alist[x][‘key’],alist[x][‘value’]

回到顶部