网页上Json格式化显示
安装
npm intall jquery-jsonview --save
引用
import 'jquery-jsonview/dist/jquery.jsonview.css';
import 'jquery-jsonview/dist/jquery.jsonview';
使用
<div id="json"></div>
var jsonString = {
"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",
"notLink": "http://jsonview.com is great",
"multiline": ['Much like me, you make your way forward,',
'Walking with downturned eyes.',
'Well, I too kept mine lowered.',
'Passer-by, stop here, please.'].join("\n")
};
$("#json").JSONView(jsonString);
效果: