Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-11-2019 02:01 PM
How to access the keys in a json document using cypher to create graph database when i don't know their names or they are arbitrary
{
"934934507945312256": {
"quote_count": 0,
"reply_count": 0,
"hashtags": null,
"datetime": "2017-11-26 23:58:51",
"date": "2017-11-26",
"like_count": 0,
"verified": "False",
"sentiment": 0,
"author": "Judy💯The Resistance",
"location": "Hollywood, California USA🇺🇸",
"tid": "934934507945312256",
"retweet_count": 0,
"type": "retweet",
"media_list": null,
"quoted_source_id": null,
"url_list": null,
"tweet_text": "RT @kylegriffin1: Reminder: The Senate Judiciary Committee gave Jared Kushner a November 27 deadline to turn over the missing records… ",
"author_profile_image": "https://pbs.twimg.com/profile_images/922041668496265216/uV8jwota_normal.jpg",
"author_screen_name": "jgirl66",
"author_id": "23737528",
"lang": "en",
"keywords_processed_list": [
"reminder",
"senate judiciary committee",
"kushner november",
"deadline"
],
"retweet_source_id": "934872065471115264",
"mentions": [
"kylegriffin1"
],
"replyto_source_id": null
},
"934933403232714752": {
"quote_count": 0,
"reply_count": 0,
"hashtags": null,
"datetime": "2017-11-26 23:54:28",
"date": "2017-11-26",
"like_count": 0,
"verified": "True",
"sentiment": 0,
"author": "GibsonVernacular.com",
"location": "Bay Area ✈ Los Angeles ",
"tid": "934933403232714752",
"retweet_count": 0,
"type": "retweet",
"media_list": null,
"quoted_source_id": null,
"url_list": null,
"tweet_text": "RT @kylegriffin1: Reminder: The Senate Judiciary Committee gave Jared Kushner a November 27 deadline to turn over the missing records… ",
"author_profile_image": "https://pbs.twimg.com/profile_images/851148627732865026/lP5uWcjn_normal.jpg",
"author_screen_name": "LuciusGibson",
"author_id": "60775653",
"lang": "en",
"keywords_processed_list": [
"reminder",
"senate judiciary committee",
"kushner november",
"deadline"
],
"retweet_source_id": "934872065471115264",
"mentions": [
"kylegriffin1"
],
"replyto_source_id": null
}
}
In this JSON file i want to first access the key "934934507945312256" and the inside it. And after that this key "934933403232714752" and data corresponding to it.
But after using the unwind option i am unable to access the key.
Because this key value is randomly generated so,i cannot know the value beforehand how can i access these values and data inside it.
here's what i have tried
WITH {json} AS document
UNWIND document AS category
FOREACH (l in category |
MERGE (label:ho{author:l.author}))
But i am getting this error:-
Cannot merge node using null property value for author
What should i do? How can i access the values inside the keys.
01-09-2020 11:15 AM
Hi @novayato
Combine apoc.map.values() with keys()
https://neo4j.com/docs/labs/apoc/3.5/data-structures/map-functions/
WITH '10941.json' as filename
CALL apoc.load.json(filename) YIELD value
WITH apoc.map.values(value, keys(value)) as items
UNWIND items as item
MERGE (label:ho{author:item.author})
All the sessions of the conference are now available online