DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:jsoneditor

JSON Editor Plugin

Compatible with DokuWiki

  • 2024-02-06 "Kaos" unknown
  • 2023-04-04 "Jack Jackrum" yes
  • 2022-07-31 "Igor" yes
  • 2020-07-29 "Hogfather" yes

plugin Integrate schema based JSON editor into json plugin.

Last updated on
2023-10-26
Provides
Syntax, Action
Repository
Source
Requires
json

Installation

Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.

Install also JSON plugin.

Description

JSON Editor Plugin (Dokuwiki plugin) is based on JSON plugin. It adds a JSON Editor to the page. JSON Editor (JavaScript library, included in the Dokuwikis JSON Editor Plugin) takes a JSON Schema and uses it to generate an HTML form. Data for the editor is defined by the JSON Plugin.

User can edit JSON data according to the rules defined in JSON Schema. When user presses 'Validate and Save' button, changed JSON data is transferred to JSON Plugin (textarea). Data can then be saved to the Dokuwiki page without page refresh.

<jsoneditor id=per_diff path=person options=%$options% schema=%$schema%></jsoneditor>

Here is a Dokuwiki JSON Demo Server with JSON database integrated into DokuWiki. Also source code of this plugin contains demo. You can copy the contents of the demo files into your Dokuwiki and experiment with them.

Support

For issues or just questions use Issues on Gitlab. Please don't email directly.

Usage

Syntax is similar as in JSON Data Plugin:
<jsoneditor attributes > inline_json </jsoneditor>

It is parsed with same parser as <json> elements, so rules for attributes and inline_json are the same. It loads JSON data the same way, from src attribute and from inline_json. It only has some extra attributes and additional tab for the editor. Data source for the editor is JSON data defined by the <jsoneditor> element (see attributes 'path', 'src', 'src_ext' and inline_json).

Attribute 'options'

It must be a valid JSON string inside single quotes. Special characters inside string, like ', < or >, can be passed by &apos;, &lt; or &gt;. Options are directly passed into JSON Editor. All JSON Editor options are freely configurable, except 'schema' and 'startval', which are set separately. Options may also be defined inside JSON database. In this case they can be referenced from there, for example options=%$path.to.editor_options%.

Global options can be specified in configuration settings for Jsoneditor ({} by default). If set, attribute 'options' is combined with global options and may also override them.

Attribute 'schema'

It must be a valid JSON Schema. Attribute has the same rules as 'options' attribute.

Attribute 'save'

It specifies, how data are stored into inline_data. If set to all, then all 'combined_data' will be stored into 'inline_data' when 'Validate and Save' button is pressed. If set to any other value or is unspecified, then only the difference from the 'original data' will be stored.

Attribute 'display'

This attribute is from JSON Data Plugin. Token 'schema' can be added to display options. It will display JSON schema used by editor in separate tab. For example: display=',schema' . To display all tabs collapsed, set for example: display=',jsoneditor' (without asterisk).

Template engines

JSON Editor (JavaScript library) uses template engines, which may automatically generate json data based on other json data. See https://github.com/json-editor/json-editor#templates. In addition to default barebones template engine, EJS template engine is also included in the plugin. EJS is disabled by default, it can be enabled in the configuration settings for json plugin. EJS gives great power to the json data: javascript (inside Dokuwiki document) can be used for calculations between json data…

  • Learn JSON - simple introduction to JSON, lightweight data-interchange format.
  • JSON Editor, a JavaScript library used by this plugin.
  • JSON Schema - should read at least “Getting started”. Contains many examples of schema.
  • JSON Schema Tool - generate sample Schema from your JSON Data online.
  • Online JSON Validator - check JSON code for Syntax Errors.
  • Regular expressions - useful for specifying patterns for strings. Learn and test online.
plugin/jsoneditor.txt · Last modified: 2023-11-12 17:06 by 89.143.170.113

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki