method getData of converting tree to json-data