How to get array inside array json data and add to single node?

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

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

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

Hi Antony
Thank you for the clarification
I have seen a similar case to yours in the forum before
Can you check the link?

1 Like

thank you i will check it out.

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.

1 Like

thank you very much andrew