JSON (JavaScript Object Notation) is one of the supported formats for data exchange. It is not only used internally by the software of MediaWiki core and many extensions, but with the help of third-party extensions the wiki itself can be a powerful vehicle for storing as well as working with JSON data. This page is about the latter.

JSON in the wiki

edit

Content model

edit

Wiki pages can have content models other than wikitext, including JSON. The simplest way to change the content model of a page to JSON is by going to 'Page information' and selecting JSON. See Manual:ContentHandler for more info.

JSON can also be stored separately in a content slot of the wiki page. For more information on content slots, see MCR.

Mixed content

edit

Although it is seen much more rarely, there are also extensions that let you use a section of a wikitext page to contain JSON content. An example is Extension:TemplateData, which offers a tag templatedata for describing a template and its parameters in the JSON format. Once stored, this information is made available (over the API) to extensions like VisualEditor.

Creating and editing JSON

edit

General purpose:

  • Extension:FlexForm - an extension for HTML5 forms which lets you create and edit JSON pages on the wiki. Supports JSON in content slots. FlexForm also supports the JSON format for creating the schema of a form.
  • Extension:WSSlots - lets you set the default content model of a slot to JSON.

Special purpose:

Code language support and Syntax highlighting

edit

Converting/exporting to JSON

edit

Even when data are not necessarily stored in JSON, there are ways to retrieve them in that format.

  • The MediaWiki API lets you interact with the wiki, using JSON as a primary format by appending &format=json to the URL. See also API:Data formats.
  • Extension:Semantic MediaWiki (SMW) - lets you use the wiki to store and query data in a database. Data can be exported in a number of result formats, including JSON. See e.g. the JSON result format and the JSON export function that comes with Datatables.
  • Many extensions come with a custom API that lets you retrieve data in JSON, including SMW, Page Forms, FlexForm, TextExtracts, etc., etc. ...
  • GoogleRichCards (beta) - generates Google Rich Cards in JSON-LD format

Reading and working with JSON

edit

See also

edit