JS JSON format string displayed in the table

JS code below, where the syntax used jq of:

<script type="text/javascript">
$(function(){
    var text = $("#show_json").html();
    var result = JSON.stringify(JSON.parse(text), null, 4);
    $("#show_json").html("<pre>"+result+"</pre>");
});
</script>

html part of the code:

<table>
            <tr>
              <td>json: </td>
              <td><p id="show_json">{"aaa":"111", "bbb":"222", "ccc":"333"}<p></td>
            </tr>
</table>

Look at renderings:

 

Guess you like

Origin www.cnblogs.com/jimmyshan-study/p/11229373.html