JSON Editor =========== [![Build Status](https://travis-ci.org/json-editor/json-editor.svg?branch=master)](https://travis-ci.org/json-editor/json-editor) Fork of the inactive [jdorn/json-editor](https://github.com/jdorn/json-editor) using the updated fork [json-editor/json-editor](https://github.com/json-editor/json-editor). Some pull requests added from the original repo. ![JSON Schema -> HTML Editor -> JSON](./docs/images/jsoneditor.png) JSON Editor takes a JSON Schema and uses it to generate an HTML form. It has full support for JSON Schema version 3 and 4 and can integrate with several popular CSS frameworks (bootstrap, foundation, and jQueryUI). Check out an interactive demo (demo.html): https://json-editor.github.io/json-editor/ Install ----------------- Install package npm install @json-editor/json-editor Using a CDN For local usage download the [production version](https://cdn.jsdelivr.net/npm/@json-editor/json-editor/dist/jsoneditor.min.js) or the [development version](https://cdn.jsdelivr.net/npm/@json-editor/json-editor/dist/jsoneditor.js) Requirements ----------------- JSON Editor has no dependencies. It only needs a modern browser (tested in Chrome and Firefox). ### Optional Requirements The following are not required, but can improve the style and usability of JSON Editor when present. * A compatible JS template engine (Mustache, Underscore, Hogan, Handlebars, Swig, Markup, or EJS) * A compatible CSS framework for styling (bootstrap 2/3, foundation 3/4/5, or jqueryui) * A compatible icon library (bootstrap 2/3 glyphicons, foundation icons 2/3, jqueryui, or font awesome 3/4) * [SCEditor](http://www.sceditor.com/) for WYSIWYG editing of HTML or BBCode content * [SimpleMDE](https://simplemde.com/) for editing of Markdown content * [Ace Editor](http://ace.c9.io/) for editing code * [Select2](http://ivaynberg.github.io/select2/) for nicer Select boxes * [Selectize](https://selectize.github.io/selectize.js/) for nicer Select & Array boxes * [math.js](http://mathjs.org/) for more accurate floating point math (multipleOf, divisibleBy, etc.) Usage -------------- If you learn best by example, check these out: * Basic Usage Example - http://rawgithub.com/jdorn/json-editor/master/examples/basic.html * Advanced Usage Example - http://rawgithub.com/jdorn/json-editor/master/examples/advanced.html * CSS Integration Example - http://rawgithub.com/jdorn/json-editor/master/examples/css_integration.html The rest of this README contains detailed documentation about every aspect of JSON Editor. For more under-the-hood documentation, check the wiki. ### Initialize ```js var element = document.getElementById('editor_holder'); var editor = new JSONEditor(element, options); ``` #### Options Options can be set globally or on a per-instance basis during instantiation. ```js // Set an option globally JSONEditor.defaults.options.theme = 'bootstrap2'; // Set an option during instantiation var editor = new JSONEditor(element, { //... theme: 'bootstrap2' }); ``` Here are all the available options:
Option | Description | Default Value |
---|---|---|
ajax | If true , JSON Editor will load external URLs in $ref via ajax. |
false |
disable_array_add | If true , remove all "add row" buttons from arrays. |
false |
disable_array_delete | If true , remove all "delete row" buttons from arrays. |
false |
disable_array_reorder | If true , remove all "move up" and "move down" buttons from arrays. |
false |
disable_collapse | If true , remove all collapse buttons from objects and arrays. |
false |
disable_edit_json | If true , remove all Edit JSON buttons from objects. |
false |
disable_properties | If true , remove all Edit Properties buttons from objects. |
false |
form_name_root | The first part of the `name` attribute of form inputs in the editor. An full example name is `root[person][name]` where "root" is the form_name_root. | root |
iconlib | The icon library to use for the editor. See the CSS Integration section below for more info. | null |
no_additional_properties | If true , objects can only contain properties defined with the properties keyword. |
false |
refs | An object containing schema definitions for URLs. Allows you to pre-define external schemas. | {} |
required_by_default | If true , all schemas that don't explicitly set the required property will be required. |
false |
keep_oneof_values | If true , makes oneOf copy properties over when switching. |
true |
schema | A valid JSON Schema to use for the editor. Version 3 and Version 4 of the draft specification are supported. | {} |
show_errors | When to show validation errors in the UI. Valid values are interaction , change , always , and never . |
"interaction" |
startval | Seed the editor with an initial value. This should be valid against the editor's schema. | null |
template | The JS template engine to use. See the Templates and Variables section below for more info. | default |
theme | The CSS theme to use. See the CSS Integration section below for more info. | html |
display_required_only | If true , only required properties will be included by default. |
false |
prompt_before_delete | If true , displays a dialog box with a confirmation message before node deletion. |
true |