Javascript examples for JSon:JSon Object
Prettify json data in textarea input
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> function prettyPrint() {//ww w .j av a 2s .com var ugly = document.getElementById('myTextArea').value; var obj = JSON.parse(ugly); var pretty = JSON.stringify(obj, undefined, 4); document.getElementById('myTextArea').value = pretty; } </script> </head> <body> <textarea id="myTextArea" cols="50" rows="10"></textarea> <button onclick="prettyPrint()">Pretty Print</button> </body> </html>