docs updated
This commit is contained in:
parent
78547dbdbc
commit
147eddc9e0
16
doc/api.md
16
doc/api.md
|
@ -35,14 +35,14 @@ Constructs a new JSONEditor.
|
||||||
- `{String} name`.
|
- `{String} name`.
|
||||||
Initial field name for the root node, is undefined by default.
|
Initial field name for the root node, is undefined by default.
|
||||||
Can also be set using `JSONEditor.setName(name)`.
|
Can also be set using `JSONEditor.setName(name)`.
|
||||||
Only applicable when mode is 'tree', 'view', or 'form'.
|
Only applicable when `mode` is 'tree', 'view', or 'form'.
|
||||||
- `{boolean} search`.
|
- `{boolean} search`.
|
||||||
Enables a search box in the upper right corner of the JSONEditor.
|
Enables a search box in the upper right corner of the JSONEditor.
|
||||||
True by default.
|
True by default.
|
||||||
Only applicable when mode is 'tree', 'view', or 'form'.
|
Only applicable when `mode` is 'tree', 'view', or 'form'.
|
||||||
- `{Number} indentation`.
|
- `{Number} indentation`.
|
||||||
Number of indentation spaces. 4 by default.
|
Number of indentation spaces. 4 by default.
|
||||||
Only applicable when mode is 'code' or 'text'.
|
Only applicable when `mode` is 'code' or 'text'.
|
||||||
|
|
||||||
- `{JSON} json`
|
- `{JSON} json`
|
||||||
Initial JSON data to be loaded into the JSONEditor. Alternatively, the method `JSONEditor.set(json)` can be used to load JSON data into the editor.
|
Initial JSON data to be loaded into the JSONEditor. Alternatively, the method `JSONEditor.set(json)` can be used to load JSON data into the editor.
|
||||||
|
@ -72,6 +72,15 @@ Set JSON data.
|
||||||
- `{JSON} json`
|
- `{JSON} json`
|
||||||
JSON data to be displayed in the JSONEditor.
|
JSON data to be displayed in the JSONEditor.
|
||||||
|
|
||||||
|
#### `JSONEditor.setMode(mode)`
|
||||||
|
|
||||||
|
Switch mode. Mode `code` requires the [Ace editor](http://ace.ajax.org/).
|
||||||
|
|
||||||
|
*Parameters:*
|
||||||
|
|
||||||
|
- `{String} mode`
|
||||||
|
Available values: `tree`, 'view', `form`, `code`, `text`.
|
||||||
|
|
||||||
#### `JSONEditor.setName(name)`
|
#### `JSONEditor.setName(name)`
|
||||||
|
|
||||||
Set a field name for the root node.
|
Set a field name for the root node.
|
||||||
|
@ -81,7 +90,6 @@ Set a field name for the root node.
|
||||||
- `{String | undefined} name`
|
- `{String | undefined} name`
|
||||||
Field name of the root node. If undefined, the current name will be removed.
|
Field name of the root node. If undefined, the current name will be removed.
|
||||||
|
|
||||||
|
|
||||||
#### `JSONEditor.setText(jsonString)`
|
#### `JSONEditor.setText(jsonString)`
|
||||||
|
|
||||||
Set text data in the formatter.
|
Set text data in the formatter.
|
||||||
|
|
19
doc/usage.md
19
doc/usage.md
|
@ -10,16 +10,16 @@ with bower:
|
||||||
|
|
||||||
npm install bower
|
npm install bower
|
||||||
|
|
||||||
downloads:
|
download:
|
||||||
|
|
||||||
[http://jsoneditoronline.org/downloads/](http://jsoneditoronline.org/downloads/)
|
[http://jsoneditoronline.org/downloads/](http://jsoneditoronline.org/downloads/)
|
||||||
|
|
||||||
The library consists of three files: one javascript file, one css file and an
|
The library consists of three files: one javascript file, one css file and an
|
||||||
image. Both full and minified version are available.
|
image. Both full and minified version are available.
|
||||||
|
|
||||||
## Load
|
## Load
|
||||||
|
|
||||||
To implement JSON Editor in a web application, load the javascript and css file
|
To implement JSONEditor in a web application, load the javascript and css file
|
||||||
in the head of the HTML page:
|
in the head of the HTML page:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
|
@ -38,8 +38,8 @@ more detailed error messages.
|
||||||
|
|
||||||
### Code editor
|
### Code editor
|
||||||
|
|
||||||
The mode 'code' requires the [Ace editor](http://ace.ajax.org/) sources to be
|
The mode 'code' requires the [Ace editor](http://ace.ajax.org/) to be loaded.
|
||||||
loaded. Also, the content type must be specified on the page.
|
Also, the content type must be specified on the page.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||||
|
@ -68,7 +68,7 @@ var options = {
|
||||||
var editor = new jsoneditor.JSONEditor(container, options);
|
var editor = new jsoneditor.JSONEditor(container, options);
|
||||||
```
|
```
|
||||||
|
|
||||||
To set JSON data, use set:
|
To set JSON data in the editor:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var json = {
|
var json = {
|
||||||
|
@ -82,7 +82,7 @@ var json = {
|
||||||
editor.set(json);
|
editor.set(json);
|
||||||
```
|
```
|
||||||
|
|
||||||
To get edited JSON data, use get:
|
To get JSON data from the editor:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var json = editor.get();
|
var json = editor.get();
|
||||||
|
@ -131,4 +131,7 @@ var json = editor.get();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
For more examples, see the
|
||||||
|
[examples section](https://github.com/josdejong/jsoneditor/tree/master/examples).
|
||||||
|
|
Loading…
Reference in New Issue