How to store array value in json to a single node. is that possible?

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

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 })

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

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 })

Thank you very much for your guidance. it really worked.

1 Like