JSON formatter lib
You can simply use the third parameter of JSON.stringify
:
success: function (data) { var obj = JSON.parse(data.ResponseBody); $("#ResponseBody").val(JSON.stringify(obj, null, 4)); },
Don't forget to add a CSS rule like #ResponseBody {white-space: pre;}
to make newlines display.
I found a very simple code to format JSON.. http://joncom.be/code/javascript-json-formatter/
Hope this will help some one..