Go to file
Kunal Mehta a839ba855d Add mw.loadJsonData()
Backporting this so the LTS release has forwards compatibility with
Wikipedia templates.

mw.loadData() allows for optimizing the loading Lua tables by requiring
only one parse and lookup. However it's often easier for people to
write/maintain bulk data in JSON rather than Lua tables.

mw.loadJsonData() has roughly the same characteristics as mw.loadData()
and it can be used on JSON content model pages in any namespace.

As noted on the linked bug report, it's possible to already implement
this by writing a wrapper Lua module that loads and parses the JSON
content. But that requires a dummy module for each JSON page, which is
just annoying and inconvenient.

Test cases are copied from the mw.loadData() ones, with a few omissions
for syntax not supported in JSON (e.g. NaN, infinity, etc.).

Bug: T217500
Change-Id: I1b35ad27a37b94064707bb8c9b7108c7078ed4d1
(cherry picked from commit 1000d322e5)
2022-11-07 07:34:42 +00:00
.phan build: Load pcntl stub to pass phan on windows 2020-06-06 13:58:24 +02:00
i18n Localisation updates from https://translatewiki.net. 2022-11-03 07:21:35 +01:00
includes Add mw.loadJsonData() 2022-11-07 07:34:42 +00:00
modules Restore padding on #mw-scribunto-input to make cursor visible 2022-10-08 22:04:09 +00:00
tests Add mw.loadJsonData() 2022-11-07 07:34:42 +00:00
.eslintrc.json build: Updating mediawiki/mediawiki-phan-config to 0.10.4 2020-11-20 17:01:25 +00:00
.gitignore build: Upgrade eslint-config-wikimedia 0.12.0, drop grunt-jsonlint 2019-05-07 10:40:41 -07:00
.gitreview Whoops, track not trace 2016-10-24 17:03:31 -07:00
.phpcs.xml Revert "Namespace LuaCommon" 2022-08-03 10:03:12 +00:00
.stylelintrc.json Use json extension for .stylelintrc 2017-08-19 10:27:54 +02:00
CODE_OF_CONDUCT.md build: Updating mediawiki/mediawiki-codesniffer to 22.0.0 2018-09-03 21:33:35 +00:00
composer.json Update mediawiki/mediawiki-phan-config to 0.11.1 2022-08-02 01:14:06 +00:00
COPYING Add strict.lua to replace "Module:No globals" 2022-11-06 21:58:19 -08:00
extension.json Revert "Namespace LuaCommon" 2022-08-03 10:03:12 +00:00
Gruntfile.js build: Updating dependencies 2021-01-30 10:41:13 +00:00
package-lock.json build: Updating ansi-regex to 5.0.1 2021-10-05 22:52:36 +00:00
package.json build: Updating dependencies 2021-09-11 22:36:44 +00:00
Scribunto.constants.php Remove PHP entry point 2019-06-21 00:02:08 +00:00
Scribunto.magic.php Add namespace and magic word translations for mnw and my 2019-10-18 20:03:05 +00:00
Scribunto.namespaces.php Namespace translations for Kyrgyz language 2022-06-09 10:06:27 +00:00