jsonfrill網頁中格式化顯示JSON字符串

下載地址: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上的版本不同,須要注意一下。調用時按這個調整下順序便可。

相關文章
相關標籤/搜索