-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
37 lines (33 loc) · 1013 Bytes
/
index.html
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
<html>
<head>
<title>json beautifier</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/json5/0.3.0/json5.min.js" integrity="sha256-4PGdv6hCb39ZQELTcL47+GesUYXF9frCRO2uppUWPuo=" crossorigin="anonymous"></script>
<style>
#json {
width: 80%;
padding: 1em;
min-height: 75%;
margin: 1em auto;
font-size: 14px;
font-family: monospace;
}
</style>
</head>
<body>
<textarea id="json"></textarea>
<pre id='j'></pre>
<script>
var params = (location.href.split('?')[1] || '').split('#')[0]
.split('&').filter(x=>x)
.map(p=>({val:p.split('=')[1], name: p.split('=')[0]}));
var param = params.find(x=>x.name=='json')
var val = param ? param.val : location.hash.slice(1)
var json = decodeURIComponent(val||'')
var pretty = JSON.stringify(JSON5.parse(json), null,2)
var el = document.getElementById('json')
el.value = pretty
el.focus()
el.select()
</script>
</body>
</html>