title: How to convert Json object into tree type in python?
body: <p>I have the following Json:</p>
  
  <pre><code> { 
     file1: {
       path_to_file: 'file1.txt',
       children : 'file2'
     },
     file2: {
       path_to_file: 'file1.txt',
       children : 'file3,file4'
     },
     file3: {
       path_to_file: 'a/file3.txt',
       children : ''
     },
     file4: {
       path_to_file: 'b/file4.txt',
       children : ''
     }
   }
  </code></pre>
  
  <p>I want to construct a tree from this Json.
  each node should have: name (file1 etc..), path_to_file which is just a data field and convert the children into "pointers" to next node.</p>
  
  <p>I have the following code:</p>
  
  <pre><code>class Node(object):
      def __init__(self, name, path_to_file=None):
          self.name = name
          self.path_to_file= path_to_file
          self.children = []
  
      def add_child(self, obj):
          self.children.append(obj)
  </code></pre>
  
  <p>This can be used as:</p>
  
  <pre><code>&gt;&gt;&gt; n = Node(5)
  &gt;&gt;&gt; p = Node(6)
  &gt;&gt;&gt; q = Node(7)
  &gt;&gt;&gt; n.add_child(p)
  &gt;&gt;&gt; n.add_child(q)
  </code></pre>
  
  <p>Now, I want to use properties from my json instead of the number above. So I have this code:</p>
  
  <pre><code>jsonObject= json.load(json_string)
  for key in jsonObject:
     value = jsonObject[key]
     print("The key and value are ({}) = ({})".format(key, value))
  </code></pre>
  
  <p>This gives me:</p>
  
  <pre><code>json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 2 column 4 (char 7)
  </code></pre>
  
  <p>How can I extract the properties in the Json object inorder to construct the call to the Node class?</p>