Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-30-2021 10:30 PM
I have a json file which is array and inside that another array is there. I want to combine them into single node. is that possible. Please have a look on json file:
"hasdata": [
{
"a": "1",
"b": "P",
"Date": "2007-05-17",
"d": [
{
"type": "Number",
"value": "617"
}
],
"Indicator": "true"
}
I want the data inside the "d" tag which have type and value. I have tried the following query
FOREACH (ab IN data.hasdata | (a:A{a:ab.a,b:ab.b,Date:ab.Date,Indicator:ab.Indicator})
except the data in "d" i was to get the rest . how can i solve this.
Any hints would be great help.
Thank you
10-01-2021 10:11 AM
Hi Antony
It seems you did not created an instance of d inside the loop as you created for the other values(a,b,date)
Regards
Rafi
10-01-2021 10:16 AM
thank you your reply. how can i create instance inside the for each for d alone. i mean if i declare "d:ab.d" this is returning error. can you show the syntax for it . do i need go for nested for each
10-01-2021 10:31 AM
Hi Antony
Thank you for the clarification
I have seen a similar case to yours in the forum before
Can you check the link?
10-01-2021 10:34 AM
thank you i will check it out.
10-01-2021 12:14 PM
The value of d
in your JSON is a list of maps. In Neo4j you can't currently use a list of maps as a property, you can at most use a list of non-structure values.
You could instead save the JSON string representation of this structure as a String property (you would need apoc.convert.toJson()
from APOC Procedures for this), or you could re-model such that instead of being saved as a property, you would model this as connected nodes, each one having the properties of the objects within the d list.
10-01-2021 10:14 PM
thank you very much andrew
All the sessions of the conference are now available online