Add JSON output for the tree.