更多操作
小无编辑摘要 标签:已被回退 |
小无编辑摘要 标签:手工回退 |
||
第1行: | 第1行: | ||
local p = {} | local p = {} | ||
-- JSON字符串 | -- JSON字符串 | ||
local json_str = [[ | local json_str = [[ | ||
{ | { |
2025年2月20日 (四) 23:37的版本
此模块的文档可以在模块:SteamPrice/doc创建
local p = {}
-- JSON字符串
local json_str = [[
{
"245170": {
"success": true,
"data": {
"price_overview": {
"currency": "CNY",
"initial": 8000,
"final": 8000,
"discount_percent": 0,
"initial_formatted": "",
"final_formatted": "¥ 80.00"
}
}
}
}
]]
-- 解析JSON字符串
local data = mw.text.jsonDecode(json_str)
-- 提取价格信息
local appid = "245170"
local priceOverview = data[appid].data.price_overview
function p.discount()
return string.format('%s', priceOverview.discount_percent)
end
function p.price()
return string.format('%s', priceOverview.final)
end
return p