forked from josdejong/jsoneditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
39 lines (36 loc) · 957 Bytes
/
demo.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
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" type="text/css" href="jsoneditor.css">
<script type="text/javascript" src="jsoneditor-min.js"></script>
</head>
<body>
<p>
<button onclick="setJSON();">Set JSON</button>
<button onclick="getJSON();">Get JSON</button>
</p>
<div id="jsoneditor" style="width: 400px; height: 400px;"></div>
<script type="text/javascript" >
// create the editor
var container = document.getElementById("jsoneditor");
var editor = new JSONEditor(container);
// set json
function setJSON () {
var json = {
"Array": [1, 2, 3],
"Boolean": true,
"Null": null,
"Number": 123,
"Object": {"a": "b", "c": "d"},
"String": "Hello World"
};
editor.set(json);
}
// get json
function getJSON() {
var json = editor.get();
alert(JSON.stringify(json, null, 2));
}
</script>
</body>
</html>