יחידה:ParamValidator: הבדלים בין גרסאות בדף
הרחבה של התיעוד בגוף היחידה |
יותר מדויק |
||
| שורה 160: | שורה 160: | ||
-- capture = capture and mw.ustring.gsub( capture, '"(%d+)"', tonumber ) -- convert "1": {} to 1: {}. frame.args uses numerical indexes for order-based params. | -- capture = capture and mw.ustring.gsub( capture, '"(%d+)"', tonumber ) -- convert "1": {} to 1: {}. frame.args uses numerical indexes for order-based params. | ||
local trailingComma = capture and mw.ustring.find( capture, ',%s*[%]%}]' ) -- look for ,] or ,} : jsonDecode allows it, but it's verbotten in json | local trailingComma = capture and mw.ustring.find( capture, ',%s*[%]%}]' ) -- look for ,] or ,} : jsonDecode allows it, but it's verbotten in json | ||
if capture and not | if capture and not trailingComma then return pcall( mw.text.jsonDecode, capture ) end | ||
return false | return false | ||
end | end | ||