查询
curl -X POST \
http://my-neo4j.example.com:7474/db/data/cypher \
-H 'Accept: application/json; charset=UTF-8' \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-H 'Postman-Token: 10c0796f-d397-4c05-8f6d-9dcde4baca8a' \
-d '{
"query" : "MATCH (c:category) RETURN c {.categoryName} ORDER BY c.categoryName"
}'
回复
{
"columns": [
"c"
],
"data": [
[
{
"categoryName": "Scenario"
}
],
[
{
"categoryName": "Theme"
}
],
[
{
"categoryName": "Video Mood"
}
]
]
}
问题:为什么结果看起来不像 this …
{
"columns": [
"c"
],
"data": [
{
"categoryName": "Scenario"
},
{
"categoryName": "Theme"
},
{
"categoryName": "Video Mood"
}
]
}
❓
答案 0 :(得分:0)
data
是一个行数组。RETURN
子句中的每一项都是一个列)。RETURN c {.categoryName}
仅返回一列。并且,由于您使用了map projection来指定列值,因此结果值是一个映射(在您的情况下,该映射包含一个字段)。如果您的查询使用的是RETURN c.categoryName
而不是RETURN c {.categoryName}
,那么您可能会发现结果不太混乱:
{
"columns": [
"c.categoryName"
],
"data": [
[
"Scenario"
],
[
"Theme"
],
[
"Video Mood"
]
]
}