To format your JSON string you can use the additional parameters of JSON.stringify
. Try something like
editor.setValue(JSON.stringify(jsonDoc, null, '\t'));
The third parameter is used for the indention per level. (Might vary in different implementations). See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify for examples.
You can also toggle display options from ace.js file.