Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-18-2019 06:57 AM
Does anybody know, if it is possible to import a json string directly via apoc.load.json instead of loading a file or an url with json data?
For example:
WITH '{
"items": [{
"question_id": 24620768,
"link": "http://stackoverflow.com/questions/24620768/neo4j-cypher-query-get-last-n-elements",
"title": "Neo4j cypher query: get last N elements",
"answer_count": 1,
"score": 1,
"creation_date": 1404771217,
"body_markdown": "I have a graph....How can I do that?",
"tags": ["neo4j",
"cypher"],
"owner": {
"reputation": 815,
"user_id": 1212067,
"link": "http://stackoverflow.com/users/1212067/"
},
"answers": [{
"owner": {
"reputation": 488,
"user_id": 737080,
"display_name": "Chris Leishman"
},
"answer_id": 24620959,
"share_link": "http://stackoverflow.com/a/24620959",
"body_markdown": "The simplest would be to use an ... some discussion on this here:...",
"title": "Neo4j cypher query: get last N elements"
}]
}]
}' as jsonString
CALL apoc.load.json(jsonString) YIELD value
UNWIND value.items as item
RETURN item.title, item.tags
Thanks in advance,
Regards, Thomas
01-18-2019 11:11 AM
You can use the function
...
WITH apoc.convert.fromJsonMap(jsonString) as value
UNWIND value.items as item
RETURN item.title, item.tags
╒═════════════════════════════════════════╤══════════════════╕
│"item.title" │"item.tags" │
╞═════════════════════════════════════════╪══════════════════╡
│"Neo4j cypher query: get last N elements"│["neo4j","cypher"]│
└─────────────────────────────────────────┴──────────────────┘
01-23-2019 02:28 AM
Thank you Michael,
I hope to find the time to try this out within the next days and will give feedback if it did the job.
Regards, Thomas
All the sessions of the conference are now available online