How do I load a JSON map in the form
{
"aaaa": {
"x": "1",
"y": "2"
},
"bbbbb": {
"x": "5",
"y": "3"
}
}
In particular, I need to get the keys "aaaa", "bbbb" ?
Thanks!
How do I load a JSON map in the form
{
"aaaa": {
"x": "1",
"y": "2"
},
"bbbbb": {
"x": "5",
"y": "3"
}
}
In particular, I need to get the keys "aaaa", "bbbb" ?
Thanks!
Hi david,
The apoc load json function supports json-paths. With a json-path query like $.*~ you should be able to fetch all top level keys from the json document.
More information on how to use the load json apoc can be found in the documentation.
https://neo4j.com/docs/labs/apoc/current/import/load-json/
Hope this helps you.
Kind regards,
Joren
Hi David,
My environment
You need the line into the neo4j.conf. (conf/neo4j.conf)
apoc.import.file.enabled=true
I created the data. (import/sample.json)
{
"aaaa": {
"x": "1",
"y": "2"
},
"bbbbb": {
"x": "5",
"y": "3"
}
}
This is the Cypher command.
WITH "sample.json" AS url
CALL apoc.load.json(url) YIELD value
UNWIND [k IN KEYS(value) | k] AS v
RETURN v
You can get all the keys.
v
"aaaa"
"bbbbb"
Thank you all.
The neo community is amazing!
If interested, I
retrieved key and value like so
CALL apoc.load.json("file:///license.json") YIELD value
UNWIND [k IN KEYS(value) | {key: k, value: value[k]}] AS obj