Module:Jf-JSON: Difference between revisions

Content deleted Content added
update from http://regex.info/code/JSON.lua
update from http://regex.info/code/JSON.lua - adds feature for dealing with trailing garbage
 
(One intermediate revision by the same user not shown)
Line 15:
-- 3) the 'AUTHOR_NOTE' string below is maintained
--
local VERSION = '2016110320161109.2021' -- version history at end of file
local AUTHOR_NOTE = "-[ JSON.lua package by Jeffrey Friedl (http://regex.info/blog/lua/json) version 2016110320161109.2021 ]-"
 
--
Line 1,058:
 
if success then
 
local error_message = nil
if next_i ~= #text + 1 then
-- something's left over after we parsed the first thing.... whitespace is allowed.
Line 1,063 ⟶ 1,065:
 
-- if we have something left over now, it's trailing garbage
local error_message
if next_i ~= #text + 1 then
value, error_message = self:onTrailingGarbage(text, next_i, value, options.etc)
Line 1,080 ⟶ 1,081:
assert(false, error_message)
end
-- ...and if we're still here (because the assert didn't throw an error),
-- return a nil and throw the error message on as a second arg
return nil, error_message
 
Line 1,431 ⟶ 1,433:
--
-- Version history:
--
-- 20161109.21 Oops, had a small boo-boo in the previous update.
--
-- 20161103.20 Used to silently ignore trailing garbage when decoding. Now fails via JSON:onTrailingGarbage()
Line 1,443 ⟶ 1,447:
-- Made the VERSION string a string instead of a number
--
 
--
-- 20160916.19 Fixed the isNumber.__index assignment (thanks to Jack Taylor)
--