json-viewer.js案例

                                                                                         json-viewer.js案例

 

【前言】插件Github地址

【需求】页面上实时预览Json字符串,相当于Json在线格式化。

【效果】

【代码(复制可用)】

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>json-viewer.js案例</title>
    <style>
        /* [jquery.json-viewer.css] START */
        /* Root element */
        .json-document {
            padding: 1em 2em;
        }

        /* Syntax highlighting for JSON objects */
        ul.json-dict, ol.json-array {
            list-style-type: none;
            margin: 0 0 0 1px;
            border-left: 1px dotted #ccc;
            padding-left: 2em;
        }
        .json-string {
            color: #0B7500;
        }
        .json-literal {
            color: #1A01CC;
            font-weight: bold;
        }

        /* Toggle button */
        a.json-toggle {
            position: relative;
            color: inherit;
            text-decoration: none;
        }
        a.json-toggle:focus {
            outline: none;
        }
        a.json-toggle:before {
            font-size: 1.1em;
            color: #c0c0c0;
            content: "\25BC"; /* down arrow */
            position: absolute;
            display: inline-block;
            width: 1em;
            text-align: center;
            line-height: 1em;
            left: -1.2em;
        }
        a.json-toggle:hover:before {
            color: #aaa;
        }
        a.json-toggle.collapsed:before {
            /* Use rotated down arrow, prevents right arrow appearing smaller than down arrow in some browsers */
            transform: rotate(-90deg);
        }

        /* Collapsable placeholder links */
        a.json-placeholder {
            color: #aaa;
            padding: 0 1em;
            text-decoration: none;
        }
        a.json-placeholder:hover {
            text-decoration: underline;
        }
        /* [jquery.json-viewer.css] END */

        body {
            margin: 0 100px;
            font-family: sans-serif;
        }
        p.options label {
            margin-right: 10px;
        }
        p.options input[type=checkbox] {
            vertical-align: middle;
        }
        textarea#json-input {
            width: 100%;
            height: 200px;
        }
        pre#json-renderer {
            border: 1px solid #aaa;
        }
    </style>
    <script src="http://libs.baidu.com/jquery/2.
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值