title: Creating nodes and relations from JSON (dynamically)
body: <p>I've got a couple hundred JSONs in a structure like the following example:</p>
  <pre><code>{
  &quot;JsonExport&quot;: [
      {
          &quot;entities&quot;: [
              {
                  &quot;identity&quot;: &quot;ENTITY_001&quot;,
                  &quot;surname&quot;: &quot;SMIT&quot;,
                  &quot;entityLocationRelation&quot;: [
                      {
                          &quot;parentIdentification&quot;: &quot;PARENT_ENTITY_001&quot;,
                          &quot;typeRelation&quot;: &quot;SEEN_AT&quot;,
                          &quot;locationIdentity&quot;: &quot;LOCATION_001&quot;
                      },
                      {
                          &quot;parentIdentification&quot;: &quot;PARENT_ENTITY_001&quot;,
                          &quot;typeRelation&quot;: &quot;SEEN_AT&quot;,
                          &quot;locationIdentity&quot;: &quot;LOCATION_002&quot;
                      }
                  ],
                  &quot;entityEntityRelation&quot;: [
                      {
                          &quot;parentIdentification&quot;: &quot;PARENT_ENTITY_001&quot;,
                          &quot;typeRelation&quot;: &quot;FRIENDS_WITH&quot;,
                          &quot;childIdentification&quot;: &quot;ENTITY_002&quot;
                      }
                  ]
              },
              {
                  &quot;identity&quot;: &quot;ENTITY_002&quot;,
                  &quot;surname&quot;: &quot;JACKSON&quot;,
                  &quot;entityLocationRelation&quot;: [
                      {
                          &quot;parentIdentification&quot;: &quot;PARENT_ENTITY_002&quot;,
                          &quot;typeRelation&quot;: &quot;SEEN_AT&quot;,
                          &quot;locationIdentity&quot;: &quot;LOCATION_001&quot;
                      }
                  ]
              },
              {
                  &quot;identity&quot;: &quot;ENTITY_003&quot;,
                  &quot;surname&quot;: &quot;JOHNSON&quot;
              }
          ],
          &quot;identification&quot;: &quot;REGISTRATION_001&quot;,
          &quot;locations&quot;: [
              {
                  &quot;city&quot;: &quot;LONDON&quot;,
                  &quot;identity&quot;: &quot;LOCATION_001&quot;
              },
              {
                  &quot;city&quot;: &quot;PARIS&quot;,
                  &quot;identity&quot;: &quot;LOCATION_002&quot;
              }
          ]
      }
  ]
  }
  </code></pre>
  <p>With these JSON's, I want to make a graph consisting of the following nodes: Registration, Entity and Location. This part I've figured out and made the following:</p>
  <pre><code>WITH &quot;file:///example.json&quot; AS json_file
  CALL apoc.load.json(json_file,&quot;$.JsonExport.*&quot; ) YIELD value AS data
  MERGE(r:Registration {id:data.identification})
  WITH json_file
  CALL apoc.load.json(json_file,&quot;$.JsonExport..locations.*&quot; ) YIELD value AS locations
  MERGE(l:Locations{identity:locations.identity, name:locations.city})
  WITH json_file
  CALL apoc.load.json(json_file,&quot;$.JsonExport..entities.*&quot; ) YIELD value AS entities
  MERGE(e:Entities {name:entities.surname, identity:entities.identity})
  </code></pre>
  <p>All the entities and locations should have a relation with the registration. I thought I could do this by using the following code:</p>
  <pre><code>MERGE (e)-[:REGISTERED_ON]-&gt;(r)
  MERGE (l)-[:REGISTERED_ON]-&gt;(r)
  </code></pre>
  <p>However this code doesn’t give the desired output. It creates extra &quot;empty&quot; nodes and doesn't connect to the registration node. So the first question is: How do I connect the location and entities nodes to the registration node. And in light of the other JSON's, the entities and locations should only be linked to the specific registration.</p>
  <p>Furthermore, I would like to make the entity -&gt; location relation and the entity - entity relation and use the given type of relation (SEEN_AT or FRIENDS_WITH) as label for the given relation. How can this be done? I'm kind of lost at this point and don’t see how to solve this. If someone could guide me into the right direction I would be much obliged.</p>