Newer
Older
import json
from pptree import *
content = json.loads(open('help.json').read())
d = {}
def add_child(key, path):
global d
item = content[key]
if 'action' in item:
n = Node(item["action"], d[path])
return None
else:
for option in item['options']:
n = Node(item["title"], d[path])
n_path = path + "-" + option
d[n_path] = n
add_child(option, n_path)
root = Node("root")
d["root"]=root
add_child("root", "root")
print_tree(root)