Extension:JSON
JSON Release status: experimental |
|||
---|---|---|---|
Implementation | Hook | ||
Description | Allows using the JSON syntax to add semantic annotations to a wiki page. | ||
Author(s) | Jie Bao (baojietalk) | ||
Latest version | 0.1 (2012-05-12) | ||
MediaWiki | 1.17+ | ||
Database changes | No | ||
License | GNU GPL v3 or later, MIT License |
||
Download | Subversion [Help] |
||
|
|||
Translate the JSON extension if it is available at translatewiki.net |
|||
Check usage and version matrix; code metrics |
The JSON extension simplifies modelling complex data structure on a semantic wiki using the JSON syntax. It is an extension of the Semantic MediaWiki extension.
Contents
What this extension does[edit | edit source]
This extension introduces a parser function "json". Example: suppose we are on page Foo with the wiki script:
{{#json: { "name" : "John", "address" : { "city" : "Boston", } } }}
The JSON extension will create the following triples
Foo#json1 name John Foo#json1 address Foo#json2 Foo#json2 city Boston Foo Has_subobject Foo#json1 Foo Has_subobject Foo#json2
Without using the JSON syntax, a wiki editor may have to explicitly create a set of short wiki pages or SMW subobjects (> SMW 1.7). The JSON syntax is shorter, and makes it easier to import data from JSON-enabled Web APIs.
Dependency[edit | edit source]
This extension is dependent on SMW 1.7 or later. It will not work without SMW.
Download and install[edit | edit source]
Download
http://smwbp.googlecode.com/svn/trunk/mediawiki/extensions/JSON/JSON.php
or use SVN
svn co http://smwbp.googlecode.com/svn/trunk/mediawiki/extensions/JSON/JSON.php
Add the code to the "WIKI-PATH/extentions/JSON" folder.
Then append the following to LocalSettings.php of your MediaWiki installation:
require_once ( "$IP/extensions/JSON/JSON.php" );
Usage[edit | edit source]
Syntax:
{{#json: THE OBJECT IN JSON FORMAT }}
You can query the generated semantic annotation using ask query as usual. To browse, e.g., Foo#json1, go to
Special:Browse/Foo-23json1
The extension introduces two special properties
- Property:Has JSON container - link a JSON node (a JSON object or part of it) to the page that contains it
- Property:Has JSON parent - link a JSON node to its parent node
In the example given at the beginning, the following additional triples will be generated:
Foo#json1 Has_JSON_container Foo Foo#json2 Has_JSON_container Foo Foo#json1 Has_JSON_parent Foo Foo#json2 Has_JSON_parent Foo#json1
Print a table of JSON nodes on a page, their parent JSON node, and their "name" property if exists.
{{#ask: [[Has JSON container::{{PAGENAME}}]] |?Has JSON parent |?name }}
Print the hierarchy of JSON objects contained on a page (this query requires Semantic Result Format 1.7.1 for tree format):
{{#ask: [[Has JSON container::{{PAGENAME}}]] |format=tree |parent=Has JSON parent }}
Limitations[edit | edit source]
Currently the extension does not support list
Related Extensions[edit | edit source]
- Extension:External Data - retrieve data from external sources with various formats, including JSON.