我想重现像这样的 Neo4j 浏览器 JSON 格式:
[
{
"p": {
"start": {
"identity": 2,
"labels": [
"Person"
],
"properties": {
"born": 1964,
"name": "Keanu Reeves"
}
},
"end": {
"identity": 155,
"labels": [
"Movie"
],
"properties": {
"title": "Something's Gotta Give",
"released": 2003
}
},
"segments": [
{
"start": {
"identity": 2,
"labels": [
"Person"
],
"properties": {
"born": 1964,
"name": "Keanu Reeves"
}
},
"relationship": {
"identity": 221,
"start": 2,
"end": 155,
"type": "ACTED_IN",
"properties": {
"roles": [
"Julian Mercer"
]
}
},
"end": {
"identity": 155,
"labels": [
"Movie"
],
"properties": {
"title": "Something's Gotta Give",
"released": 2003
}
}
}
],
"length": 1
}
},
{
"p": {
"start": {
"identity": 2,
"labels": [
"Person"
],
"properties": {
"born": 1964,
"name": "Keanu Reeves"
}
},
"end": {
"identity": 88,
"labels": [
"Movie"
],
"properties": {
"tagline": "Pain heals, Chicks dig scars... Glory lasts forever",
"title": "The Replacements",
"released": 2000
}
},
"segments": [
{
"start": {
"identity": 2,
"labels": [
"Person"
],
"properties": {
"born": 1964,
"name": "Keanu Reeves"
}
},
"relationship": {
"identity": 114,
"start": 2,
"end": 88,
"type": "ACTED_IN",
"properties": {
"roles": [
"Shane Falco"
]
}
},
"end": {
"identity": 88,
"labels": [
"Movie"
],
"properties": {
"tagline": "Pain heals, Chicks dig scars... Glory lasts forever",
"title": "The Replacements",
"released": 2000
}
}
}
],
"length": 1
}
}
]
我尝试使用 httpie 命令来执行此操作,以检索发送到事务密码端点的内容,但我得到了一些数据、行和元数据。
我的目标是通过 Cypher 请求检索我的数据库的一部分,并通过 Python 检索,JSON 就像 Neo4j 浏览器按钮之一。
感谢您的帮助!
你可以通过Python检索,并保持为dict类型,然后你可以使用json来保存这个带有参数“indent”的dict。
import json
my_dict = {'name': ['Raphael', 'Donatello'],
'mask': ['red', 'purple'],
'weapon': ['sai', 'bo staff']}
with open('/Users/peter/temp/test.json', 'w', encoding='utf-8') as f:
json.dump(my_dict, f, indent=2)
我认为this可能有帮助。另请查看页面顶部可能的 JSON 格式。