title: Represent directory tree as JSON
body: <p>Is there any easy way to generate such a JSON? I found <code>os.walk()</code> and <code>os.listdir()</code>, so I may do recursive descending into directories and build a python object, well, but it sounds like reinventing a wheel, maybe someone knows working code for such a task?</p>
  
  <pre><code>{
    "type": "directory",
    "name": "hello",
    "children": [
      {
        "type": "directory",
        "name": "world",
        "children": [
          {
            "type": "file",
            "name": "one.txt"
          },
          {
            "type": "file",
            "name": "two.txt"
          }
        ]
      },
      {
        "type": "file",
        "name": "README"
      }
    ]
  }
  </code></pre>