html文件格式化json的案例编码

空话很少说了,立即给大伙儿贴编码了,实际编码以下所示:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf⑻">
  <title>JS Bin</title>
  <link rel="stylesheet" href="https://rawgithub.com/yesmeck/jquery-jsonview/master/dist/jquery.jsonview.css" />
  <script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
  <script type="text/javascript" src="https://rawgithub.com/yesmeck/jquery-jsonview/master/dist/jquery.jsonview.js"></script>
  <script type="text/javascript">
var json = {"hey": "guy","anumber": 243,"anobject": {"whoa": "nuts","anarray": [1,2,"thr<h1>ee"],"anotherarray": [1, 2], "more":"stuff"},"awesome": true,"bogus": false,"meaning": null, "japanese":"明天がある。", "link": "http://jsonview.com", "notLink": "http://jsonview.com is great"};
$(function() {
  $('#json').JSONView(json);
  $('#collapse-btn').on('click', function() {
    $('#json').JSONView('collapse');
  });
  $('#expand-btn').on('click', function() {
    $('#json').JSONView('expand');
  });
  $('#toggle-btn').on('click', function() {
    $('#json').JSONView('toggle');
  });
  $('#toggle-level1-btn').on('click', function() {
    $('#json').JSONView('toggle', 1);
  });
  $('#toggle-level2-btn').on('click', function() {
    $('#json').JSONView('toggle', 2);
  });
});
  </script>
</head>
<body>
  <br/>
  <button id="collapse-btn">Collapse</button>
  <button id="expand-btn">Expand</button>
  <button id="toggle-btn">Toggle</button>
  <button id="toggle-level1-btn">Toggle level1</button>
  <button id="toggle-level2-btn">Toggle level2</button>     <div id="json"></div>
</body>
</html>

如demo所示,显示信息文件格式化的json

以上所述是网编给大伙儿详细介绍的html文件格式化json的案例编码,期待对大伙儿有一定的协助,假如大伙儿有任何疑惑请给我留言,网编会立即回应大伙儿的。在此也十分谢谢大伙儿对脚本制作之家网站的适用!