| Vorlagenprogrammierung | Diskussionen | Lua | Test | Unterseiten | |||
| Modul | Deutsch | English | Modul: | Dokumentation | |||
JSONutil – Module with functions for preparation, analysis and generation of JSON code strings.
Line breaks and tabulators within string values will be accepted and converted.
Rather than a global “Invalid” message it will be tried to detect some typical errors and communicate them together with context.
Another functionality is generating JSON source code from template syntax.
The Failsafe interface is heading for version management of globally distributed Lua modules. It enables modules equipped with this interface to
The Failsafe interface is present both at template level and for direct Lua access.
The functions in detail are (not all supported yet completely by every library):
| Value | Result | current |
|---|---|---|
nothingfalse |
local version ID | »2020-11-08« |
| Minimal version | version ID required at least date in ISO format It will be compared whether the current local implementation matches this version or later.
|
|
wikidata |
version ID of global upstream
|
»2020-11-08« |
item |
ID of the Wikidata item
|
Q63869449 |
~ |
Corresponding version ID locally and registered at Wikidata
|
»« |
@ |
Is the current (module) page linked correctly with Wikidata item?
|
|
The return value is in template programming empty or under Lua false, otherwis a non-empty string as described. | ||
These functions generate JSON source code from template syntax.
All functions described above can be used by other modules:
local lucky, JSONutil = pcall( require, "Module:JSONutil" )
if type( JSONutil ) == "table" then
JSONutil = JSONutil.JSONutil()
else
-- failure; JSONutil is the error message
return "<span class=\"error\">" .. JSONutil .. "</span>"
end
Subsequently there are available:
"wikidata"false if no complaints.true, if always preemptive test for free line format and strict JSON code being performedThe argument adapt provides adaption of message language and might be one of these types:
function – Callback
string – space-separated list of preferred language codestrue, if non-numeric elements shall trigger errorsnull false 0 - will result in false, else true"NaN"None.
General library.