-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
124 lines (110 loc) · 3.19 KB
/
index.html
File metadata and controls
124 lines (110 loc) · 3.19 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
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>json-util</title>
<link rel="stylesheet" href="less.css">
<script type="text/javascript" src="//cdn.jsdelivr.net/json2/0.2/json2.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">
function syntaxHighlightJSON(json) {
json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
json = json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
var cls = 'number';
if (/^"/.test(match)) {
if (/:$/.test(match)) {
cls = 'key';
} else {
cls = 'string';
}
} else if (/true|false/.test(match)) {
cls = 'boolean';
} else if (/null/.test(match)) {
cls = 'null';
}
return '<span class="' + cls + '">' + match + '</span>';
});
json = json.replace(/(\{|\[)/g, "<span class='pojo'>$&<span class='members'>").replace(/(\]|\})/g, '</span>$&</span>');
return json;
}
$(function () {
$('.src').keyup(function () {
$('.dstPretty').html('');
var obj = JSON.parse($('.src').val());
$('.dstPretty').html(syntaxHighlightJSON(JSON.stringify(obj, null, ' ')));
}).scroll(function () {
$('.src').scrollTop
}).keyup();
$('.numberType').click(function () {
$('.src').keyup();
});
$('.dstPretty').on('click', '.pojo', function () {
$(this).toggleClass('fold');
return false;
}).on('click', '.members', function () {
return false;
});
});
</script>
</head>
<body class="jsonUtil">
<div class="wrap">
<h1>nativebinary - jsonPrettier</h1>
<h4>
<a href="https://nativebinary.github.io/json-util/">jsonPrettier</a> |
<a href="https://nativebinary.github.io/json-util/jsonToJava.html">jsonToJava</a> |
<a href="https://nativebinary.github.io/json-util/ddlToJava.html">ddlToJava</a> |
<a href="https://nativebinary.github.io/json-util/generatePassword.html">generatePassword</a> |
<a href="https://nativebinary.github.io/json-util/mybatisBind.html">mybatisBind</a> |
</h4>
<textarea class="src">{
"s1": "s1",
"s2": "55",
"i1": 10,
"i2": 20.0,
"d1": 5.5,
"d2": 55.55,
"b1": true,
"b2": false,
"o1" : {
"s1": "s1",
"s2": "s2",
"i1": 10,
"i2": 20,
"d1": 5.5,
"d2": 55.55,
"b1": true,
"b2": false,
"listAggregate": [
{ "a": "A"},
{ "b": "B"},
{ "c": "C"},
{ "d": "D"}
],
"listOfInt": [ 1, 2, 3, 4 ],
"listOfDouble": [ 1.1, 2.2, 3.3, 4.4 ],
"listOfBoolean": [ true, false, true, false ],
"listOfString": [ "A", "B", "C", "D" ],
"deep" : {
"deep": {
"deep": {
"deep": {
"deep1": {
"empty": {
}
},
"deep2": [1, 2, 3]
}
}
}
}
},
"O2" : {
"i": 10
}
}</textarea>
<div class="dstPretty json"></div>
</div>
</body>
</html>