Read nested json

**I AM new to neo4j. Can anyone help me creating cypher query for below json.
I've a path array in my code which contains three objects, i want to get 3 separate nodes as path1, path2, path3 containing x, y, z properties in each path respectively.
thanks in advance.
**

{
"nets": [{
			"name": "Net 0",
			"path": [{
						"x": 0.949999988079071,
						"y": 0.009999999776482582,
						"z": 0.20000000298023224
					}, {
						"x": 0.949999988079071,
						"y": 0.009999999776482582,
						"z": 0.6000000238418579
					}, {
						"x": -0.8499999642372131,
						"y": 0.009999999776482582,
						"z": 0.6000000238418579
					}
				],
			"pins": [[0, 2], [1, 1]]
		}, {
			"name": "Net 1",
			"path": [{
						"x": 5.25,
						"y": 0.009999999776482582,
						"z": 0
					}, {
						"x": 5.25,
						"y": 0.009999999776482582,
						"z": 0.20000000298023224
					}, {
						"x": 2.049999952316284,
						"y": 0.009999999776482582,
						"z": 0.20000000298023224
					}
				],
			"pins": [[-1, 1], [0, 1]]
		}, {
			"name": "Net 2",
			"path": [{
						"x": -1.9500000476837158,
						"y": 0.009999999776482582,
						"z": 0.6000000238418579
					}, {
						"x": -1.9500000476837158,
						"y": 0.009999999776482582,
						"z": 0
					}, {
						"x": -5.150000095367432,
						"y": 0.009999999776482582,
						"z": 0
					}
				],
			"pins": [[1, 2], [-1, 2]]
		}
	]
}

Hi, there is an issue you should consider in your model. Currently, It is not possible to add nested property as a property (path values). So you may have to create separate nodes.

UNWIND ['13171.json'] as filename
CALL apoc.load.json(filename) YIELD value AS v
WITH v.nets as nets
UNWIND nets as net
WITH net
MERGE (Net:NetNode {name: net.name})
	FOREACH (xyz in net.path | MERGE (Net)-[:has_xyz]->(:XYZ {x: xyz.x, y: xyz.y, z:xyz.z}))

If you unpack your XYZ values into separate nodes you can get something like that.

2 Likes

Thank for great help!!!!

Hi, everyone.
Could I echo this question?
If I already create those nodes in neo4j database, does Neo4j have any possibility to run a MATCH
with nested JSON property?
Just using Neo4j ETL tool to transfer those data from MYSQL to Neo4j, and I still try to think how to separate those nodes.