JSON output of elements tree