Ace editor doesn't format the data inside the editor div
ace-editor, javascript
Solution
Ace doesn't support formatting the code, you can either use beautify.js or browsers built-in json formatter
var val = editor.session.getValue()
var o = JSON.parse(val) // may throw if json is malformed
val = JSON.stringify(o, null, 4) // 4 is the indent size
editor.session.setValue(val)
Problem
I have embedded some `JSON` data inside the editor div. as here : http://jsfiddle.net/P3TwV/11/ But as shown in the fiddle, the JSON is not being formatted. It simply put the data in one line. i want the data, that i inputed in single line without any spaces, should get automatically formatted with proper indenting, according to the specified type as here JSON and all the folding and unfolding of the objects inside the editor should get enable. How do i approach that? Any answer will help me here. Thank you.