print tree in json format