User:Rand(1,2022)/JSON

Just some quick notes because so little of it is documented, or only in scattered places.

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

Content model
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.

Creating and editing JSON
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:
 * GeoJSON:
 * Extension:Maps - lets you store GeoJSON in a dedicated namespace, with a Leaflet-based editor to edit maps, and lets you use GeoJSON data in maps.
 * Extension:Kartographer supports inline GeoJSON within the mapframe tag
 * Extension:JsonConfig - lets you store JSON on a wiki page in order for other extensions to store their configuration data as a JSON blob.
 * Extension:TemplateData - lets you store data about your template in JSON, making them available for use by extensions like Extension:VisualEditor.
 * Exntesion:PageProperties - lets you annotate JSON-LD within a wiki page.

Converting/exporting to JSON
Even when data are not necessarily stored in JSON, there may be ways to retrieve them as JSON.
 * The MediaWiki API lets you interact with the wiki, using JSON as a primary format.
 * API:JSON version 2
 * Extension:Semantic MediaWiki - lets you the 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, [[Extension:TextExtracts, etc., etc. ...
 * GoogleRichCards (beta) - generates Google Rich Cards in JSON-LD format

Reading and working with JSON

 * Extension:Scribunto - adds Lua to your wiki and offers Lua functions to load, decode and encode JSON data. See the descriptions of mw.loadJsonData, mw.text.jsonDecode and mw.text.jsonEncode on Extension:Scribunto/Lua reference manual.
 * Extension:WSSlots - can be used to fetch the JSON content from a slot. Comes with functions for Lua.
 * Extension:External Data - lets you query JSON from a URL or file on the server. Comes with support for JSONPath.