Output tree in JSON

Write trees to json by providing the same functionality as XmlProcessor.

Followed current XML implementation. The similarity between them shows that a third output would warrant a template of some sorts.