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.

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

JSON can also be stored separately in a MCR slot of the wiki page.

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:
 * 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: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.

Converting/exporting to JSON
Even when data are not necessarily stored in JSON, there may be ways to retrieve them as JSON.
 * MediaWiki API
 * 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 Page Forms, FlexForm, ...

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.