Template:Json2table
This documentation is transcluded from Template:Json2table/doc.
Category:Main message boxesCategory:Lua-based templates
Description
This template lets you display tabular data stored on Wikimedia Commons as a regular wiki-table. It is adapted from the former English-Wikipedia version (now deleted there and replaced by templates based on en:Module:Tabular data).
Usage
{{Json2table|dataset=...}}
dataset
– **required**. Page name (without the “Data:” prefix) in the Commons **Data:** namespace, e.g.
COVID-19 hospitalizations in Denmark
for Data:COVID-19 hospitalizations in Denmark.tab
row_header
– (defaulttrue
) make the first column header-styled (bold).col_header
– (defaulttrue
) use the column names as table headers.caption
– (defaulttrue
) use the dataset’s description as the table caption.empty_cell
– (default “ ”) text to show when the JSON value isnull
.columns
– (default *all*) list of column keys (defined inschema.fields.name
) to include, separated with “/”.table_format
– (defaultclass="wikitable"
) extra wikitext for the opening<table>
tag.bare
– (defaultfalse
) output only the table’s rows and cells (wrap them yourself).nowiki
– (defaultfalse
) show the table’s wikitext instead of rendering it (debugging aid).lang
– language code to pick the correct translation from multilingual fields; if omitted the site’s content language (English on Commons) is used.
Examples
Default
{{Json2table|dataset=Chart Example Data}}
produces
Default
{{Json2table|dataset=COVID-19 hospitalizations in Denmark}}
produces
Selected columns
{{Json2table|dataset=COVID-19 hospitalizations in Denmark
|columns=date/hospitalizations
|caption=false |row_header=false
|table_format=class="wikitable sortable"}}
produces
Datum | Sjukhusinlagda |
---|---|
11 mars 2020 | 10 |
13 mars 2020 | 23 |
14 mars 2020 | 23 |
15 mars 2020 | 28 |
16 mars 2020 | 62 |
17 mars 2020 | 82 |
18 mars 2020 | 129 |
19 mars 2020 | 153 |
20 mars 2020 | 186 |
21 mars 2020 | 206 |
22 mars 2020 | 232 |
23 mars 2020 | 254 |
24 mars 2020 | 301 |
25 mars 2020 | 350 |
26 mars 2020 | 386 |
27 mars 2020 | 430 |
28 mars 2020 | 459 |
29 mars 2020 | 499 |
30 mars 2020 | 533 |
31 mars 2020 | 529 |
1 april 2020 | 535 |