Add support for JSON formatting

Resolves #2
Fixes issue with xml declarations