-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
219 lines (197 loc) · 9.12 KB
/
index.html
File metadata and controls
219 lines (197 loc) · 9.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<title>JSON 在线解析、格式化、校验工具</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="JsonTool.cn 是一个专业的 JSON 在线工具网站,提供多种功能,如 JSON 解析、格式化、校验、压缩、编辑、美化、JSON 转 XML、JSON 教程等。网站页面简洁,配色美观,并支持在格式化结果上进行自定义操作,如 JSON 块展开、折叠等,极大方便用户使用。" />
<meta name="keywords" content="json在线解析工具,json在线解析网站,json在线,json格式化,json解析网站,json工具在线,json.cn,json cn,json工具,json校验,json美化,json解析,在线json格式校验,jsonlint" />
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
<meta name="baidu-site-verification" content="code-K26efHPQnS" />
<link rel="shortcut icon" href="/img/favicon.ico" />
<link rel="bookmark" href="/img/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.1.4/toastr.min.css" />
<link rel="stylesheet" type="text/css" href="css/base.v3.css" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.8/clipboard.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.1.4/toastr.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/layer/3.5.1/layer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/json2/20160511/json2.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jsonlint/1.6.0/jsonlint.min.js"></script>
<script type="text/javascript" src="js/main.js"></script>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?267ef29dfb3196f78212c359de75eb55";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</head>
<body>
<!-- 导航栏 -->
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<!-- <a class="navbar-brand" href="#">
<img alt="Brand" src="img/logo.png" height=40 width=200>
</a> -->
<a class="navbar-brand" href="/" text="Jsontool.cn">Jsontool.cn</a>
<!-- <p class="navbar-text">JSON 在线解析、格式化、校验</p> -->
</div><!-- /.navbar-header -->
<div id="navbar" class="collapse navbar-collapse navbar-right">
<ul class="nav navbar-nav">
<li><a href="/" target="_blank">首页</a></li>
<li><a href="courses/index.html" target="_blank">教程</a></li>
<li><a href="mailto:jsontool@163.com">投诉/建议</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container -->
</nav>
<!-- <link href="css/base.css" rel="stylesheet" /> -->
<!-- 主要内容区域 -->
<main class="row-fluid">
<!-- 左边文本框 -->
<div class="col-md-5" style="padding:0;">
<textarea id="json-src" placeholder="在此输入json字符串或XML字符串..." class="form-control" style="padding:20px;border:0;border-right:solid 1px #ddd;border-radius:0;resize: none; outline:none;">{"i":200,"str":"ok"}</textarea>
</div>
<!-- 右边文本框和功能按钮 -->
<div class="col-md-7" style="padding:0;">
<div style="padding:7px;font-size:16px;border-bottom:solid 1px #ddd;" class="navi">
<a href="#" class="zip" title="压缩" data-placement="bottom"><i class="fa fa-compress"></i></a>
<a href="#" class="xml" title="转XML" data-placement="bottom"><i class="fa fa-file-excel-o"></i></a>
<a href="#" class="copy" title="复制" data-clipboard-target="#json-target" data-placement="bottom"><i class="fa fa-copy"></i></a>
<a href="#" class="clear" title="清空" data-placement="bottom"><i class="fa fa-eraser"></i></a>
<a href="#" class="fullScreen" title="全屏" data-placement="bottom" style="cursor:no-drop;"><i class="fa fa-arrows-alt"></i></a>
</div>
<div id="json-target" style="padding:20px;border-right:solid 1px #ddd;border-radius:0;resize: none;overflow-y:scroll; outline:none;">
</div>
<!-- <form id="form-save" method="POST"><input type="hidden" value="" id="txt-content" name="content"></form> -->
</div>
</main>
<script>
window.onload = function() {
var footerHeight = document.querySelector('footer').offsetHeight;
var navHeight = document.querySelector('nav').offsetHeight;
var windowHeight = window.innerHeight;
var mainHeight = windowHeight - (footerHeight + navHeight) + 2;
document.getElementById('json-src').style.height = mainHeight + 'px';
document.getElementById('json-target').style.height = mainHeight - 45 + 'px';
};
</script>
<script src="js/jquery.json.js"></script>
<script src="js/jquery.xml2json.js"></script>
<script src="js/jquery.json2xml.js"></script>
<script type="text/javascript">
var current_json = '';
var current_json_str = '';
var xml_flag = false;
var zip_flag = false;
function init(){
xml_flag = false;
zip_flag = false;
$('.xml').attr('style','color:#999;');
$('.zip').attr('style','color:#999;');
}
$('#json-src').keyup(function(){
init();
var content = $.trim($(this).val());
var result = '';
if (content!='') {
//如果是xml,那么转换为json
if (content.substr(0,1) === '<' && content.substr(-1,1) === '>') {
try{
var json_obj = $.xml2json(content);
content = JSON.stringify(json_obj);
}catch(e){
result = '解析错误:<span style="color: #f1592a;font-weight:bold;">' + e.message + '</span>';
current_json_str = result;
$('#json-target').html(result);
return false;
}
}
try{
current_json = jsonlint.parse(content);
current_json_str = JSON.stringify(current_json);
//current_json = JSON.parse(content);
result = new JSONFormat(content,4).toString();
}catch(e){
result = '<span style="color: #f1592a;font-weight:bold;">' + e + '</span>';
current_json_str = result;
}
$('#json-target').html(result);
}else{
$('#json-target').html('');
}
});
$('.zip').click(function(){
if (zip_flag) {
$('#json-src').keyup();
}else{
$('#json-target').html(current_json_str);
zip_flag = true;
$(this).attr('style','color:#15b374;');
}
});
$('.xml').click(function(){
if (xml_flag) {
$('#json-src').keyup();
}else{
var result = $.json2xml(current_json);
$('#json-target').html('<textarea style="width:100%;height:100%;border:0;resize:none;">'+result+'</textarea>');
xml_flag = true;
$(this).attr('style','color:#15b374;');
}
});
var clipboard = new ClipboardJS('.copy');
clipboard.on('success', function(e) {
toastr.options.timeOut = 30;
toastr.success("已复制");
e.clearSelection();
});
clipboard.on('error', function(e) {
toastr.options.timeOut = 30;
toastr.error("复制失败");
});
// $('.copy').click(function () {
// $.msg("成功复制到粘贴板","color:#00D69C;");
// $(this).tooltip('toggle')
// .attr('data-original-title', "复制成功!")
// .tooltip('fixTitle')
// .tooltip('toggle');
// });
$('.clear').click(function(){
$('#json-src').val('');
$('#json-target').html('');
});
// $('.save').click(function(){
// var content = JSON.stringify(current_json);
// $('#txt-content').val(content);
// $("#form-save").submit();
// });
$('#json-src').keyup();
// function getWinHeight() {
// var winHeight = 0;
// if (window.innerHeight)
// winHeight = window.innerHeight;
// else if ((document.body) && (document.body.clientHeight))
// winHeight = document.body.clientHeight;
// return winHeight;
// }
// $(window).resize(function() {
// $('#json-src').css('height', getWinHeight() - 97);
// $('#json-target').css('height', getWinHeight() - 141);
// });
// $(window).resize();
</script>
<!--footer start-->
<footer class="fixed_footer">
<div id="copyright">
© 2021<script>new Date().getFullYear()>2021&&document.write("-"+new Date().getFullYear());</script> <a href="/">JsonTool.cn</a>, All rights reserved.
</div>
</footer>
</body>
</html>