Json Formatter Lib
I'm looking for a way to format (as in whitespace, newlines where suitable) a JSON result so that I can display the actual result but well formatted. $.ajax({ url:
Solution 1:
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.
Solution 2:
JSONLint includes that functionality
Solution 3:
I found a very simple code to format JSON.. http://joncom.be/code/javascript-json-formatter/
Hope this will help some one..
Post a Comment for "Json Formatter Lib"