title: How to convert a JSON file to a graph with library networkx in Python?
body: <p>I have a big JSON file and I want to convert it with networkx library to a graph.
  The JSON file contains so many nodes like:</p>
  <p>{&quot;data&quot;: [{
  &quot;d&quot;: 2,
  &quot;source&quot;: &quot;C&quot;,
  &quot;target&quot;: &quot;L&quot;
  },...]}</p>
  <p>I already opened the JSON file and I extracted each &quot;data&quot; dictionary inside the JSON file. However, I do not know how to use networkx to convert all of my source, target nodes with considering the attribute &quot;d&quot; to a graph.</p>
  <pre class="lang-py prettyprint-override"><code>import networkx as nx
  import json
  
  lst = list()
  with open('json_file.json') as json_load:
      data = json.load(json_load)
      lst.extend( data[&quot;edges&quot;])  
      d, src, tgt = [],[], [], [] 
      
      for elem in lst:
        d.append(elem[&quot;data&quot;][&quot;d&quot;])
        src.append(elem[&quot;data&quot;][&quot;source&quot;])
        tgt.append(elem[&quot;data&quot;][&quot;target&quot;])
  
  G = nx.Graph()      
  G.add_edges_from([tuple(zip(src, tgt))])
  </code></pre>
  <p>When I wrote the last line for inserting the edges into the G graph, it did not really work. I had an error. I guess because I did not properly merge the source and target nodes together.</p>
  <p>Also, I have another problem as well. I couldn’t figure out how to consider attribute &quot;d&quot; for each node in the graph as well.</p>