Convert directory structure to json?
<p>I want to convert a project hierarchy with some properties for each class or package in a JSON dictionary. for example</p>

<p>I am using python for this. Can anyone please give me some basic outline. How I can implement this.Thank you. thus i want something like:</p>

<pre><code>a = package, a.b = package, a.b.c = class, a.b.d = class

j_string = {
    "my_data": {
        "a": "info": {},
        "b": {
            "info": {},
            "c": {
                "info": {}
            },
            "d": {
                "info": {}
            }
        }
    }
}
</code></pre>

<p>try to use <code>pkgutil.walk_packages</code> combine with <code>importlib.import_module</code>.</p>

<pre><code>def get_all_module_of_a_package(pkg_name):
    pkg = importlib.import_module(pkg_name)
    for importer, name, is_pkg in pkgutil.walk_packages(pkg.__path__, pkg.__name__ + '.'):
        if is_pkg:
            continue
        print name # I just print them, you can build a dict you desired
        # do some other things (if you want to get member of a module)
        # use inspect.getmembers



&gt;&gt;&gt; get_all_module_of_a_package('json')
json.decoder
json.encoder
json.scanner
json.tests.test_check_circular
json.tests.test_decode
json.tests.test_default
json.tests.test_dump
json.tests.test_encode_basestring_ascii
json.tests.test_fail
json.tests.test_float
json.tests.test_indent
json.tests.test_pass1
json.tests.test_pass2
json.tests.test_pass3
json.tests.test_recursion
json.tests.test_scanstring
json.tests.test_separators
json.tests.test_speedups
json.tests.test_tool
json.tests.test_unicode
json.tool
</code></pre>

python json