46 lines
1.0 KiB
HTML
46 lines
1.0 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<link rel="stylesheet" type="text/css" href="../jsoneditor.css">
|
|
<script type="text/javascript" src="../jsoneditor.js"></script>
|
|
<style type="text/css">
|
|
#jsoneditor {
|
|
width: 500px;
|
|
height: 500px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<p>
|
|
<button id="setJSON">Set JSON</button>
|
|
<button id="getJSON">Get JSON</button>
|
|
</p>
|
|
<div id="jsoneditor"></div>
|
|
|
|
<script type="text/javascript" >
|
|
// create the editor
|
|
var container = document.getElementById('jsoneditor');
|
|
var editor = new jsoneditor.JSONEditor(container);
|
|
|
|
// set json
|
|
document.getElementById('setJSON').onclick = function () {
|
|
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
|
|
document.getElementById('getJSON').onclick = function () {
|
|
var json = editor.get();
|
|
alert(JSON.stringify(json, null, 2));
|
|
};
|
|
</script>
|
|
</body>
|
|
</html>
|