Demo:JSON - datatype export examples

From semantic-mediawiki.org
Table of Contents


Query with different datatypes[edit]

Syntax
{{#ask:
 [[Has_annotation_uri::+]]
 |?Has_annotation_uri=anu
 |?Has_boolean=boo
 |?Has_code=cod
 |?Has_date=dat
 |?Has email address=ema
 |?Has Wikidata item ID=eid
 |?Has coordinates=geo
 |?Has number=num
 |?Has mlt=mlt
 |?Has example=wpg
 |?Telephone number=tel
 |?Has temperatureExample=tem
 |?Area=qty
 |?SomeProperty=txt
 |?Has Wikidata Reference=ref_rec
 |?Soccer result=rec
 |?Has_URL=uri
 |format=json
 |limit=1
}}
Result as List
  1. List of datatypes (anu: https://www.semantic-mediawiki.org, boo: true, cod:
    Code
    is preserved but variables are expanded, e.g:
    Help:List of datatypes
    is displayed as the name of this page instead of FULLPAGENAME
    , dat: 22 May 2015 17:32:00, ema: president@whitehouse.gov, geo: 32° 42' 54.00" N, 117° 9' 45.00" W, num: 47,000.11, mltGeneric property for monolingual text: Monoglingual text in english (en), Texte monoglinguel en français (fr), Einsprachiger Text auf Deutsch (de), wpg: Semantic MediaWiki, telThis property is a special property in this wiki.: +1-800-225-5288, tem: 296.15 K23 °C <br />73.4 °F <br />533.07 °R <br />, qty: 1,052.00 km²406.18 sqmi <br />, txt: Did you create the page for Tokyo 東京 ? Yes ✓, rec: 2015-03-22;Bayern München;Borussia Mönchengladbach;0;2, uri: http://www.whitehouse.gov)

... further results

Result as json

JSON

json source code
{
    "printrequests": [
        {
            "label": "",
            "key": "",
            "redi": "",
            "typeid": "_wpg",
            "mode": 2,
            "format": false
        },
        {
            "label": "anu",
            "key": "Has_annotation_uri",
            "redi": "",
            "typeid": "_anu",
            "mode": 1,
            "format": ""
        },
        {
            "label": "boo",
            "key": "Has_boolean",
            "redi": "",
            "typeid": "_boo",
            "mode": 1,
            "format": ""
        },
        {
            "label": "cod",
            "key": "Has_code",
            "redi": "",
            "typeid": "_cod",
            "mode": 1,
            "format": ""
        },
        {
            "label": "dat",
            "key": "Has_date",
            "redi": "",
            "typeid": "_dat",
            "mode": 1,
            "format": ""
        },
        {
            "label": "ema",
            "key": "Has_email_address",
            "redi": "",
            "typeid": "_ema",
            "mode": 1,
            "format": ""
        },
        {
            "label": "eid",
            "key": "Has_Wikidata_item_ID",
            "redi": "",
            "typeid": "_eid",
            "mode": 1,
            "format": ""
        },
        {
            "label": "geo",
            "key": "Has_coordinates",
            "redi": "",
            "typeid": "_geo",
            "mode": 1,
            "format": ""
        },
        {
            "label": "num",
            "key": "Has_number",
            "redi": "",
            "typeid": "_num",
            "mode": 1,
            "format": ""
        },
        {
            "label": "mlt",
            "key": "Has_mlt",
            "redi": "",
            "typeid": "_mlt_rec",
            "mode": 1,
            "format": ""
        },
        {
            "label": "wpg",
            "key": "Has_example",
            "redi": "",
            "typeid": "_wpg",
            "mode": 1,
            "format": ""
        },
        {
            "label": "tel",
            "key": "_tel",
            "redi": "",
            "typeid": "_tel",
            "mode": 1,
            "format": ""
        },
        {
            "label": "tem",
            "key": "Has_temperatureExample",
            "redi": "",
            "typeid": "_tem",
            "mode": 1,
            "format": ""
        },
        {
            "label": "qty",
            "key": "Area",
            "redi": "",
            "typeid": "_qty",
            "mode": 1,
            "format": ""
        },
        {
            "label": "txt",
            "key": "SomeProperty",
            "redi": "",
            "typeid": "_txt",
            "mode": 1,
            "format": ""
        },
        {
            "label": "ref_rec",
            "key": "Has_Wikidata_Reference",
            "redi": "",
            "typeid": "_ref_rec",
            "mode": 1,
            "format": ""
        },
        {
            "label": "rec",
            "key": "Soccer_result",
            "redi": "",
            "typeid": "_rec",
            "mode": 1,
            "format": ""
        },
        {
            "label": "uri",
            "key": "Has_URL",
            "redi": "",
            "typeid": "_uri",
            "mode": 1,
            "format": ""
        }
    ],
    "results": {
        "Help:List of datatypes": {
            "printouts": {
                "anu": [
                    "https:\/\/www.semantic-mediawiki.org"
                ],
                "boo": [
                    "t"
                ],
                "cod": [
                    "Code\nis preserved but variables are expanded, e.g:\nHelp:List of datatypes\nis displayed as the name of this page instead of FULLPAGENAME"
                ],
                "dat": [
                    {
                        "timestamp": "1432315920",
                        "raw": "1\/2015\/5\/22\/17\/32\/0\/0"
                    }
                ],
                "ema": [
                    "mailto:president@whitehouse.gov"
                ],
                "eid": [
                    "Q9682"
                ],
                "geo": [
                    {
                        "lat": 32.715,
                        "lon": -117.1625
                    }
                ],
                "num": [
                    47000.11
                ],
                "mlt": [
                    {
                        "Text": {
                            "label": "Text",
                            "key": "_TEXT",
                            "typeid": "_txt",
                            "item": [
                                "Monoglingual text in english"
                            ]
                        },
                        "Language code": {
                            "label": "Language code",
                            "key": "_LCODE",
                            "typeid": "__lcode",
                            "item": [
                                "en"
                            ]
                        }
                    },
                    {
                        "Text": {
                            "label": "Text",
                            "key": "_TEXT",
                            "typeid": "_txt",
                            "item": [
                                "Texte monoglinguel en fran\u00e7ais"
                            ]
                        },
                        "Language code": {
                            "label": "Language code",
                            "key": "_LCODE",
                            "typeid": "__lcode",
                            "item": [
                                "fr"
                            ]
                        }
                    },
                    {
                        "Text": {
                            "label": "Text",
                            "key": "_TEXT",
                            "typeid": "_txt",
                            "item": [
                                "Einsprachiger Text auf Deutsch"
                            ]
                        },
                        "Language code": {
                            "label": "Language code",
                            "key": "_LCODE",
                            "typeid": "__lcode",
                            "item": [
                                "de"
                            ]
                        }
                    }
                ],
                "wpg": [
                    {
                        "fulltext": "Semantic MediaWiki",
                        "fullurl": "https:\/\/www.semantic-mediawiki.org\/wiki\/Semantic_MediaWiki",
                        "namespace": 0,
                        "exists": "1",
                        "displaytitle": ""
                    }
                ],
                "tel": [
                    "tel:+1-800-225-5288"
                ],
                "tem": [
                    296.15
                ],
                "qty": [
                    {
                        "value": 1052,
                        "unit": "km\u00b2"
                    }
                ],
                "txt": [
                    "Did you create the page for Tokyo \u6771\u4eac ? Yes \u2713"
                ],
                "ref_rec": [
                    {
                        "Has URL": {
                            "label": "Has URL",
                            "key": "Has_URL",
                            "typeid": "_uri",
                            "item": [
                                "https:\/\/en.wikipedia.org\/wiki\/Data_type"
                            ]
                        },
                        "Has Wikidata item ID": {
                            "label": "Has Wikidata item ID",
                            "key": "Has_Wikidata_item_ID",
                            "typeid": "_eid",
                            "item": [
                                "Q190087"
                            ]
                        }
                    }
                ],
                "rec": [
                    {
                        "Soccer date": {
                            "label": "Soccer date",
                            "key": "Soccer_date",
                            "typeid": "_dat",
                            "item": [
                                {
                                    "timestamp": "1426982400",
                                    "raw": "1\/2015\/3\/22"
                                }
                            ]
                        },
                        "Soccer home team": {
                            "label": "Soccer home team",
                            "key": "Soccer_home_team",
                            "typeid": "_wpg",
                            "item": [
                                {
                                    "fulltext": "Bayern M\u00fcnchen",
                                    "fullurl": "https:\/\/www.semantic-mediawiki.org\/wiki\/Bayern_M%C3%BCnchen",
                                    "namespace": 0,
                                    "exists": "",
                                    "displaytitle": ""
                                }
                            ]
                        },
                        "Soccer guest team": {
                            "label": "Soccer guest team",
                            "key": "Soccer_guest_team",
                            "typeid": "_wpg",
                            "item": [
                                {
                                    "fulltext": "Borussia M\u00f6nchengladbach",
                                    "fullurl": "https:\/\/www.semantic-mediawiki.org\/wiki\/Borussia_M%C3%B6nchengladbach",
                                    "namespace": 0,
                                    "exists": "1",
                                    "displaytitle": ""
                                }
                            ]
                        },
                        "Soccer homescore": {
                            "label": "Soccer homescore",
                            "key": "Soccer_homescore",
                            "typeid": "_num",
                            "item": [
                                0
                            ]
                        },
                        "Soccer guestscore": {
                            "label": "Soccer guestscore",
                            "key": "Soccer_guestscore",
                            "typeid": "_num",
                            "item": [
                                2
                            ]
                        }
                    }
                ],
                "uri": [
                    "http:\/\/www.whitehouse.gov"
                ]
            },
            "fulltext": "Help:List of datatypes",
            "fullurl": "https:\/\/www.semantic-mediawiki.org\/wiki\/Help:List_of_datatypes",
            "namespace": 12,
            "exists": "1",
            "displaytitle": ""
        }
    },
    "serializer": "SMW\\Serializers\\QueryResultSerializer",
    "version": 2,
    "rows": 1
}

List of datatype IDs[edit]

IDDatatypeDescriptionin this wikiHelp pageProvided by
_anu
Annotation URIHolds URIs, but has some technical differences during export compared to the "URL" typeTypes/Annotation URIHelp:Datatype "Annotation URI"Semantic MediaWiki
_boo
BooleanHolds boolean (true/false) valuesTypes/BooleanHelp:Datatype "Boolean"Semantic MediaWiki
_cod
CodeHolds technical, pre-formatted texts (similar to datatype Text)Types/CodeHelp:Datatype "Code"Semantic MediaWiki
_dat
DateHolds particular points in timeTypes/DateHelp:Datatype "Date"Semantic MediaWiki
_ema
EmailHolds e-mail addressesTypes/EmailHelp:Datatype "Email"Semantic MediaWiki
_eid
External identifierHolds a value that associates it with with a external URI for formattingTypes/External identifierHelp:Datatype "External identifier"Semantic MediaWiki
_geo
Geographic coordinatesHolds coordinates describing geographic locationsTypes/Geographic coordinatesHelp:Datatype "Geographic coordinates"Maps (Semantic Maps)
_keyw
KeywordHolds text of restricted length that is being normalised (similar to datatype Text)Types/KeywordHelp:Datatype "Keyword"Semantic MediaWiki
_mlt_rec
Monolingual textHolds a text value that associates the annotation with a specific language codeTypes/Monolingual textHelp:Datatype "Monolingual text"Semantic MediaWiki
_num
NumberHolds integer and decimal numbers, with an optional exponentTypes/NumberHelp:Datatype "Number"Semantic MediaWiki
_wpg
PageHolds names of wiki pages, and displays them as a linkTypes/PageHelp:Datatype "Page"Semantic MediaWiki
_qty
QuantityHolds values that describe quantities, containing both a number and a unitTypes/QuantityHelp:Datatype "Quantity"Semantic MediaWiki
_rec
RecordHolds compound property values that consist of a short list of values with fixed type and orderTypes/RecordHelp:Datatype "Record"Semantic MediaWiki
_tel
Telephone numberHolds international telephone numbers based on the RFC 3966 standardTypes/Telephone numberHelp:Datatype "Telephone number"Semantic MediaWiki
_tem
TemperatureHolds temperature values (similar to type Quantity)Types/TemperatureHelp:Datatype "Temperature"Semantic MediaWiki
_txt
TextHolds text of arbitrary lengthTypes/TextHelp:Datatype "Text"Semantic MediaWiki
_ref_rec
ReferenceHolds a value that associates it to individual defined provenance metadata recordTypes/ReferenceHelp:Datatype "Reference"Semantic MediaWiki
_uri
URLHolds URIs, URNs and URLsTypes/URLHelp:Datatype "URL"Semantic MediaWiki