Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-27-2021 04:14 AM
I have a json file and i want to store the multiple values in a single node. is that possible. Please have a look on json file:
"abstract":
[
{
"value": "<p>chinese</p>",
"language": "chi"
},
{
"value": "<p>eng</p>",
"language": "eng"
}
i want to store eng and chinese , values and language into a single node. I have written cypher query , but its taking only the first value and first langue, discarding the second one. This is query i have written "FOREACH (abst IN data.abstract | MERGE (abs:Abstract{value:abst.value}) ON CREATE SET abs.language=abst.language," .Any idea or hint will be great help.
Thank you
Solved! Go to Solution.
09-27-2021 09:30 AM
Here is the reference:
apoc.load.json - APOC Documentation (neo4j.com)
CALL apoc.load.json("file:///D:/mm.json") YIELD value
UNWIND value.abstract as abstractItem
MERGE (a:Abstract {value: abstractItem.value, language: abstractItem.language })
09-27-2021 08:30 AM
node properties can store arrays, but not arrays of objects.
For your example you'd want a collection of nodes with each of the objects properties mapped to the node properties.
UNWIND $abstract as abstractItem
MERGE (a:Abstract {value: abstractItem.value, language: abstractItem.language })
09-27-2021 09:09 AM
Thank you very much for your reply. I have tried as mentioned above but its throwing error with "Expected Parameter(s): abstract" . I'm new to neo4j, my querying is not top class. This is code I have tired:
CALL apoc.load.json("file:///D:/mm.json") YIELD value AS abstract
UNWIND $abstract as abstractItem
MERGE (a:Abstract {value: abstractItem.value, language: abstractItem.language })
What I have to correct in the above query.
Thank you
09-27-2021 09:30 AM
Here is the reference:
apoc.load.json - APOC Documentation (neo4j.com)
CALL apoc.load.json("file:///D:/mm.json") YIELD value
UNWIND value.abstract as abstractItem
MERGE (a:Abstract {value: abstractItem.value, language: abstractItem.language })
09-27-2021 09:32 AM
Thank you very much for your guidance. it really worked.
All the sessions of the conference are now available online