{{< jsoneditor >}}

Description#


The jsoneditor shortcode allows to display a form based on a JSON Schema. This form can then be used to export (copy to clipboard/download as a file) the resulting JSON.

Parameters#


NameType(named/positional)Description
sourcenamedSource of the JSON Schema.
NB: The source can be either a local path or an URL.
postAnalyzeFunctionnamed

Name of the global Javascript method to run specific and additionnal validation right after the Jsoneditor standard validation.

  • input: JSON Schema, JSON generated from JSON Schema by Jsoneditor
  • output: Array of errors (Empty array if no errors), with errors of type:
    {
      path: [FIELD_ERROR_PATH],
      message: [ERROR_MESSAGE]
    }
    
postProcessFunctionnamed

Name of the global Javascript method to run specific and additionnal process right after the Jsoneditor standard JSON generation.

  • input: JSON Schema, JSON generated from JSON Schema by Jsoneditor
  • output: JSON to export
filenameToDownloadFunctionnamed

Name of the global Javascript method to define filename to download.

  • input: JSON Schema, JSON generated from JSON Schema by Jsoneditor
  • output: Filename to download

NB: By default filename will be equal to schema.title or fallback to the ID of the jsoneditor HTML container.

jsoneditor.js
// Function to run additionnal process after standard JSON Schema validation in jsoneditor
window.examplePostAnalyzeFunction = function examplePostAnalyzeFunction(schema, json) {
  return [{path: 'root.dummy', message: 'A dummy error'}]
}
// Function to run additionnal process after standard JSON process in jsoneditor
window.examplePostProcessFunction = function examplePostProcessFunction(schema, json) {
  return 'An example post process JSON'
}
// Function to define filename to download
window.exampleFilenameToDownloadFunction = function exampleFilenameToDownloadFunction(schema, json) {
  return 'exampleFile.json'
}

Examples#


MarkdownRendering
{{</* jsoneditor source="https://raw.githubusercontent.com/json-schema-org/website/main/public/data/getting-started-examples/schemas/default.json" */>}}
Loading
{{</* jsoneditor
  source="https://raw.githubusercontent.com/json-schema-org/website/main/public/data/getting-started-examples/schemas/default.json"
  postAnalyzeFunction="examplePostAnalyzeFunction"
*/>}}
Loading
{{</* jsoneditor
  source="https://raw.githubusercontent.com/json-schema-org/website/main/public/data/getting-started-examples/schemas/default.json"
  postProcessFunction="examplePostProcessFunction"
*/>}}
Loading
{{</* jsoneditor
  source="https://raw.githubusercontent.com/json-schema-org/website/main/public/data/getting-started-examples/schemas/default.json"
  filenameToDownloadFunction="exampleFilenameToDownloadFunction"
*/>}}
Loading
{{</* jsoneditor source="jsoneditor/example.json" */>}}
Loading