Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-11-2020 09:36 AM
I need to create a node that has a latitude and longitude property.
Those values are in a map within a list called "locations".
I thought of a simple approach; create a loop and try indexing into it but I get an error (expected a map but was list).
WITH $json as jsonFile
FOREACH (x in jsonFile.response.landmarkAnnotations.locations |
MERGE(n:Location {latitude: x.latLng.latitude, longitude: x.latLng.longitude}))
what other methods can I try and what can I read up on to give me an understanding of how to fix my problem?
Here's the json file
{
"url": "https:\/\/farm5.staticflickr.com\/4469\/23531804118_fce6162cd1.jpg",
"response":
{
"labelAnnotations":
[
{
"score": 0.85065764188766,
"mid": "\/m\/07yv9",
"description": "vehicle"
},
...
],
"webDetection":
{
"fullMatchingImages":
[
{
"url": "https:\/\/farm6.staticflickr.com\/5079\/7403056606_a09f6f670e_b.jpg"
},
...
],
"pagesWithMatchingImages":
[
{
"url": "http:\/\/picssr.com\/photos\/32622429@N02\/favorites\/page109?nsid=32622429@N02"
},
...
],
"webEntities":
[
{
"score": 3.0824000835419,
"entityId": "\/m\/02vqfm",
"description": "Coffee"
},
...
],
"partialMatchingImages":
[
{
"url": "https:\/\/farm6.staticflickr.com\/5079\/7403056606_a09f6f670e_b.jpg"
},
...
]
},
"landmarkAnnotations":
[
{
"score": 0.78584295511246,
"mid": "\/m\/02dpsq",
"description": "Williamsburg Bridge",
"locations": [ { "latLng": { "latitude": 40.712001800537, "longitude": -73.97216796875 } } ]
},
...
]
}
}
Solved! Go to Solution.
10-11-2020 10:11 AM
Hello @Shukaku and welcome to the Neo4j community
WITH $json AS jsonFile
UNWIND jsonFile.response.landmarkAnnotations AS la
MERGE (n:Location {latitude: la.locations[0].latLng.latitude, longitude: la.locations[0].latLng.longitude}))
Regards,
Cobra
10-11-2020 10:11 AM
Hello @Shukaku and welcome to the Neo4j community
WITH $json AS jsonFile
UNWIND jsonFile.response.landmarkAnnotations AS la
MERGE (n:Location {latitude: la.locations[0].latLng.latitude, longitude: la.locations[0].latLng.longitude}))
Regards,
Cobra
10-11-2020 05:47 PM
Hello, @Cobra, thank you!
This was valuable in understanding what I was missing!
All the sessions of the conference are now available online