-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
try-json5and6.html
54 lines (54 loc) · 2.4 KB
/
try-json5and6.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.7/require.min.js" integrity="sha512-J5ha2LF4Le+PBQnI5+xAVJDR+sZG9uSgroy4n/A6TLjNkvYQbqZA8WHZdaOvJ0HiKkBC9Frmvs10rFDSHKmveQ==" crossorigin="anonymous"></script>
<script type="text/javascript">
require.config({
paths: {
json5: "https://unpkg.com/[email protected]/dist/index",
json6: "https://unpkg.com/[email protected]/dist/index",
},
waitSeconds: 40
});
</script>
<script src="https://unpkg.com/[email protected]/lib/jsox.js"></script>
</head>
<body>
<textarea id="input"></textarea>
<pre id="output3"></pre>
<pre id="output5"></pre>
<pre id="output6"></pre>
<pre id="outputx"></pre>
<script>
require(["json5", "json6"],
function (JSON5, JSON6) {
document.getElementById('input').addEventListener('input', (evt) => {
const value = evt.target.value
try {
const object = JSON.parse(value)
document.getElementById('output3').textContent = 'JSON:\n'+JSON.stringify(object, null, 2)
} catch (e) {
document.getElementById('output3').textContent = 'JSON:\n'+e.message
}
try {
const object = JSON5.parse(value)
document.getElementById('output5').textContent = 'JSON5:\n'+JSON5.stringify(object, null, 2)
} catch (e) {
document.getElementById('output5').textContent = 'JSON5:\n'+e.message
}
try {
const object = JSON6.parse(value)
document.getElementById('output6').textContent = 'JSON6:\n'+JSON6.stringify(object, null, 2)
} catch (e) {
document.getElementById('output6').textContent = 'JSON6:\n'+e.message
}
try {
const object = JSOX.parse(value)
document.getElementById('outputx').textContent = 'JSOX:\n'+JSOX.stringify(object, null, 2)
} catch (e) {
document.getElementById('outputx').textContent = 'JSOX:\n'+e.message
}
})
}
)
</script>
</body>