下载地址:css
https://github.com/sparuvu/jsonfrilljquery
用法:git
依赖于jquery,版本大于1.10.2github
引入cssjson
<link href="src/jsonFrill.css" rel="stylesheet">spa
引入jsip
<script src="src/jsonFrill.js"></script>get
准备一个divit
<div id="jsoncontainer" style="overflow-y:auto; overflow-x:auto; width:500px; height:595px;"></div>io
js中初始化,传入json内容content
$('#jsoncontainer').jsonFrill(content)
或者加入参数配置:
$('#jsoncontainer').jsonFrill(content,{collapse: true, toolbar: true, tabSize: 2});
说明:
本人在网上找的jsonFrill版本,如上的初始化方法无效。查看源代码,jsonFrill的方法声明是:function(options, jsonSource)
必需要加参数,且参数的顺序跟官方github上的版本不同,须要注意一下。调用时按这个调整下顺序便可。