Module:FilterJsonById

From AoP Wiki
Revision as of 09:00, 19 February 2025 by Zmeja (talk | contribs) (Testing)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:FilterJsonById/doc

-- Module:JsonDataParser

local json = mw.json  -- Import the JSON decoder

-- Example JSON data (replace with actual content, or load via an external method)
local jsonData = [[
  {
    "Armor_Trait_1": 6,
    "Armor_DTExplode": 4,
    "Armor_CrTypeFemale": 7,
    "Tradeability": 4,
    "Armor_AC": 0,
    "Material": 1,
    "Armor_Trait_3": 8,
    "Description": "Polished metal plates, crudely forming a suit of armor.",
    "Armor_CrTypeMale": 14,
    "Deteriorable": 1,
    "Subtype": 4,
    "Armor_DRExplode": 15,
    "Flags": 134217758,
    "GroundLevel": 1,
    "Armor_DTPlasma": 5,
    "Armor_DTElectr": 0,
    "Armor_DRLaser": 60,
    "Armor_DTFire": 3,
    "PicInv": "art/armor/mtlarmor.png",
    "Armor_DREmp": 500,
    "ProtoId": 2,
    "Armor_DRNormal": 35,
    "DisableEgg": 1,
    "SoundId": 48,
    "Armor_Trait_4": 8,
    "Armor_Trait_2": 8,
    "PicMap": "art/items/ground_metalarmor.fofrm",
    "Armor_Trait_0": 3,
    "Armor_DTNormal": 13,
    "Type": 1,
    "Armor_DRPlasma": 10,
    "Armor_DRElectr": 0,
    "Armor_Trait_5": 25,
    "Cost": 0,
    "Name": "Metal Armor",
    "Armor_DTLaser": 8,
    "Armor_DRFire": 5,
    "Tier": 1,
    "Weight": 15000
  }
]]

-- local data = json.decode(jsonData)  -- Decode the JSON content into a Lua table

-- Create a table of extracted data
--[[ local resultTable = {
  name = data.Weight,
  age = data.Weight,
  location = data.Weight,
  occupation = data.Weight
}
]]--

local exampleTable = {
  name = "John",
  age = 25,
  location = "New York"
}

mw.log("Debugging table: " .. mw.dumpObject(exampleTable))


-- Return the table to be used in the wiki page
return data