Skip to content

Instantly share code, notes, and snippets.

@kishorek
Created May 20, 2021 14:24
Show Gist options
  • Save kishorek/ca0ad427793b4a7a53edef10e8af0275 to your computer and use it in GitHub Desktop.
Save kishorek/ca0ad427793b4a7a53edef10e8af0275 to your computer and use it in GitHub Desktop.
Quick Simple JSON Editor HTML
<!DOCTYPE html>
<html lang="en">
<head>
<!-- when using the mode "code", it's important to specify charset utf-8 -->
<meta charset="utf-8" />
<link
href="https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/9.4.1/jsoneditor.min.css"
rel="stylesheet"
type="text/css"
/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/9.4.1/jsoneditor.min.js"></script>
<style type="text/css">
body {
font: 10.5pt arial;
color: #4d4d4d;
line-height: 150%;
width: 500px;
}
code {
background-color: #f5f5f5;
}
#jsoneditor {
width: 900px;
height: 600px;
}
</style>
</head>
<body>
<div id="jsoneditor"></div>
<script>
const container = document.getElementById("jsoneditor");
const options = {
mode: "code",
modes: ["code", "form", "text", "tree", "view", "preview"], // allowed modes
onError: function (err) {
alert(err.toString());
},
onModeChange: function (newMode, oldMode) {
console.log("Mode switched from", oldMode, "to", newMode);
},
};
const json = {};
const editor = new JSONEditor(container, options, json);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment