JSON查看jQuery插件:JSONView
jQuery JSONView 是一個以更加可讀的格式查看 JSON 的插件。
var json = {"hey": "guy","anumber": 243,"anobject": {"whoa": "nuts","anarray": [1,2,"thr<h1>ee"], "more":"stuff"},"awesome": true,"bogus": false,"meaning": null, "japanese":"明日がある。", "link": "http://jsonview.com is great"};$(function() { $("#json").JSONView(json); // with options $("#json-collasped").JSONView(json, { collapsed: true }); });</pre>
Options
jQuery JSONView can be configured using the following options.
- collapsed- Collapse all nodes when rendering first time, default isfalse.
- nl2br- Convert new line to<br>in String, default isfalse.
- recursive_collapser- Collapse nodes recursively, default isfalse.
API
jQuery JSONView provide following methods to allow you control JSON nodes, all methods below accept a level argument to perform action on the specify node.
- jQuery#JSONView('collapse', [level])- Collapse nodes.
- jQuery#JSONView('expand', [level])- Expand nodes.
- jQuery#JSONView('toggle', [level])- Toggle nodes.

本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!