<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.hoodedhorse.com/MENACE/index.php?action=history&amp;feed=atom&amp;title=Module%3AJsonUtils</id>
	<title>Module:JsonUtils - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.hoodedhorse.com/MENACE/index.php?action=history&amp;feed=atom&amp;title=Module%3AJsonUtils"/>
	<link rel="alternate" type="text/html" href="https://wiki.hoodedhorse.com/MENACE/index.php?title=Module:JsonUtils&amp;action=history"/>
	<updated>2026-09-23T00:14:15Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.5</generator>
	<entry>
		<id>https://wiki.hoodedhorse.com/MENACE/index.php?title=Module:JsonUtils&amp;diff=343&amp;oldid=prev</id>
		<title>76561197968631074: 76561197968631074 moved page Module:Jsonutils to Module:JsonUtils: Misspelled title</title>
		<link rel="alternate" type="text/html" href="https://wiki.hoodedhorse.com/MENACE/index.php?title=Module:JsonUtils&amp;diff=343&amp;oldid=prev"/>
		<updated>2025-09-28T03:54:21Z</updated>

		<summary type="html">&lt;p&gt;76561197968631074 moved page &lt;a href=&quot;/MENACE/Module:Jsonutils&quot; class=&quot;mw-redirect&quot; title=&quot;Module:Jsonutils&quot;&gt;Module:Jsonutils&lt;/a&gt; to &lt;a href=&quot;/MENACE/Module:JsonUtils&quot; title=&quot;Module:JsonUtils&quot;&gt;Module:JsonUtils&lt;/a&gt;: Misspelled title&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 03:54, 28 September 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key MEN_:diff:1.41:old-342:rev-343 --&gt;
&lt;/table&gt;</summary>
		<author><name>76561197968631074</name></author>
	</entry>
	<entry>
		<id>https://wiki.hoodedhorse.com/MENACE/index.php?title=Module:JsonUtils&amp;diff=342&amp;oldid=prev</id>
		<title>76561197968631074: Created page with &quot;--- ---Uses mw.text.jsonDecode to convert the specified JSON file on the wiki into a Lua table. --- ---The page must contain properly formatted JSON data and only the JSON data, without any explanation, wiki markup, or other content. --- ---The table returned may have missing fields where they would otherwise be expected if the JSON data contained nil values for those fields. --- ---@module JsonUtils local JsonUtils = {}    --region Dependencies -- none --endregion    --...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.hoodedhorse.com/MENACE/index.php?title=Module:JsonUtils&amp;diff=342&amp;oldid=prev"/>
		<updated>2025-09-28T03:32:17Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;--- ---Uses mw.text.jsonDecode to convert the specified JSON file on the wiki into a Lua table. --- ---The page must contain properly formatted JSON data and only the JSON data, without any explanation, wiki markup, or other content. --- ---The table returned may have missing fields where they would otherwise be expected if the JSON data contained nil values for those fields. --- ---@module JsonUtils local JsonUtils = {}    --region Dependencies -- none --endregion    --...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;---&lt;br /&gt;
---Uses mw.text.jsonDecode to convert the specified JSON file on the wiki into a Lua table.&lt;br /&gt;
---&lt;br /&gt;
---The page must contain properly formatted JSON data and only the JSON data, without any explanation, wiki markup, or other content.&lt;br /&gt;
---&lt;br /&gt;
---The table returned may have missing fields where they would otherwise be expected if the JSON data contained nil values for those fields.&lt;br /&gt;
---&lt;br /&gt;
---@module JsonUtils&lt;br /&gt;
local JsonUtils = {}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--region Dependencies&lt;br /&gt;
-- none&lt;br /&gt;
--endregion&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--region Private constants&lt;br /&gt;
&lt;br /&gt;
local ERROR_MESSAGE_PARAMETER_MISSING = &amp;quot;JsonUtils requires as its parameter that you provide the name of a page on the wiki that contains valid JSON data. Call the main function with a parameter that is the name of the desired page, like this:\n  `JsonUtils.main(&amp;#039;Template:Data_json`)`&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local ERROR_PREFIX_TITLE_INVALID_NAME = &amp;quot;JsonUtils failed to create a Mediawiki title object with the page name you provided. Double-check that the page name you provided is a properly formatted string and valid page title: &amp;quot;&lt;br /&gt;
local ERROR_PREFIX_TITLE_PAGE_DOES_NOT_EXIST = &amp;quot;JsonUtils checked the page name you provided, and the page does not exist. Double-check that the page name you provided is correct: &amp;quot;&lt;br /&gt;
&lt;br /&gt;
local ERROR_PREFIX_CONTENT_NOT_FOUND = &amp;quot;JsonUtils did not find content on the page whose name you provided. Double check that the page exists and that it contains content: &amp;quot;&lt;br /&gt;
local ERROR_PREFIX_CONTENT_NOT_LONG_ENOUGH = &amp;quot;JsonUtils found content on the page whose name you provided, but it is too short to be useful. Double-check that you provided the correct name, and that there is content on the page: &amp;quot;&lt;br /&gt;
&lt;br /&gt;
local ERROR_PREFIX_JSON_DATA_NOT_USABLE = &amp;quot;JsonUtils loaded the content on the page, but parsing it as JSON data was not successful. Double-check that the page you provided contains properly formatted JSON data: &amp;quot;&lt;br /&gt;
local ERROR_PREFIX_JSON_NO_DATA = &amp;quot;JsonUtils loaded and parsed the content on the page you provided, but parsing it as JSON data yielded an empty table. Double-check that the page you provided contains more than one JSON record: &amp;quot;&lt;br /&gt;
&lt;br /&gt;
local MINIMUM_LENGTH_THAT_SUGGESTS_VALID_CONTENT = 4&lt;br /&gt;
&lt;br /&gt;
--endregion&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--region Private member variables&lt;br /&gt;
-- none&lt;br /&gt;
--endregion&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--region Private methods&lt;br /&gt;
-- none&lt;br /&gt;
--endregion&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--region Public methods&lt;br /&gt;
&lt;br /&gt;
---Loads JSON data from the specified page on the wiki into a Lua table.&lt;br /&gt;
---@param wikiPageName string the title of the wiki page, including&lt;br /&gt;
---@return table&lt;br /&gt;
function JsonUtils.convertJSONToLuaTable(wikiPageName)&lt;br /&gt;
&lt;br /&gt;
    -- Verify the parameter.&lt;br /&gt;
    if not wikiPageName or &amp;quot;&amp;quot; == wikiPageName then&lt;br /&gt;
        error(ERROR_MESSAGE_PARAMETER_MISSING)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Verify that the name is valid and that the page exists.&lt;br /&gt;
    local titleObject = mw.title.new(wikiPageName)&lt;br /&gt;
    if not titleObject then&lt;br /&gt;
        error(ERROR_PREFIX_TITLE_INVALID_NAME .. wikiPageName)&lt;br /&gt;
    end&lt;br /&gt;
    if not titleObject.exists then&lt;br /&gt;
        error(ERROR_PREFIX_TITLE_PAGE_DOES_NOT_EXIST .. wikiPageName)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Verify that the page content can be loaded and that there is something there to use.&lt;br /&gt;
    local unparsedContent = titleObject:getContent()&lt;br /&gt;
    if not unparsedContent then&lt;br /&gt;
        error(ERROR_PREFIX_CONTENT_NOT_FOUND .. wikiPageName)&lt;br /&gt;
    end&lt;br /&gt;
    if #unparsedContent &amp;lt; MINIMUM_LENGTH_THAT_SUGGESTS_VALID_CONTENT then&lt;br /&gt;
        error(ERROR_PREFIX_CONTENT_NOT_LONG_ENOUGH .. wikiPageName)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Verify that the data is valid and useful JSON.&lt;br /&gt;
    local success, decodedTable = pcall(mw.text.jsonDecode, unparsedContent)&lt;br /&gt;
    if not success or not decodedTable then&lt;br /&gt;
        error(ERROR_PREFIX_JSON_DATA_NOT_USABLE .. wikiPageName)&lt;br /&gt;
    end&lt;br /&gt;
    if #decodedTable &amp;lt; 1 then&lt;br /&gt;
        error(ERROR_PREFIX_JSON_NO_DATA .. wikiPageName)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return decodedTable&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--endregion&lt;br /&gt;
&lt;br /&gt;
return JsonUtils&lt;/div&gt;</summary>
		<author><name>76561197968631074</name></author>
	</entry>
</feed>