-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
79 lines (71 loc) · 1.66 KB
/
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
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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>JSON loose</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap-reboot.min.css"
/>
<style>
.content {
max-width: 760px;
margin: 0 auto;
padding: 3rem 1rem;
}
pre {
margin-bottom: 3rem;
padding: 1rem;
background-color: var(--bs-secondary-bg);
border-radius: 0.5rem;
}
</style>
</head>
<body>
<div class="content">
<h2>Input</h2>
<pre id="input"></pre>
<h2>Output</h2>
<pre id="output"></pre>
</div>
<script src="https://cdn.jsdelivr.net/npm/moo/moo.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/json-loose/dist/index.umd.js"></script>
<script>
const input = `[
"foo",
true,
[1, 2, wife],
{
[n]: 'Bambang Ekalaya',
username: "@palgunadi",
age: 30,
address: [{city:city}, [country]],
skills: skills,
isStudent: true,
relation: {
wife: wife,
guru: guru,
[bar]: "qux"
},
},
]`
const context = {
n: "name",
skills: "Archery",
city: "Nishada",
country: "Aravalli",
wife: "Anggraini",
guru: "Drona"
}
const output = JSON.parse(jsonLoose(input, context))
console.log(output)
document.querySelector("#input").textContent = input
document.querySelector("#output").textContent = JSON.stringify(
output,
null,
2
)
</script>
</body>
</html>