diff options
Diffstat (limited to 'macros/luatex/generic/lualibs/lualibs-util-jsn.lua')
-rw-r--r-- | macros/luatex/generic/lualibs/lualibs-util-jsn.lua | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/macros/luatex/generic/lualibs/lualibs-util-jsn.lua b/macros/luatex/generic/lualibs/lualibs-util-jsn.lua index 8da3518979..2d78561971 100644 --- a/macros/luatex/generic/lualibs/lualibs-util-jsn.lua +++ b/macros/luatex/generic/lualibs/lualibs-util-jsn.lua @@ -17,6 +17,10 @@ if not modules then modules = { } end modules ['util-jsn'] = { -- -- Upgraded for handling the somewhat more fax server templates. +if utilities and utilities.json then + return json +end + local P, V, R, S, C, Cc, Cs, Ct, Cf, Cg = lpeg.P, lpeg.V, lpeg.R, lpeg.S, lpeg.C, lpeg.Cc, lpeg.Cs, lpeg.Ct, lpeg.Cf, lpeg.Cg local lpegmatch = lpeg.match local format, gsub = string.format, string.gsub @@ -265,6 +269,8 @@ do k = lpegmatch(escaper,k) or k v = lpegmatch(escaper,v) or v n = n + 1 t[n] = f_key_val_str(depth,k,v) + elseif i > 1 then + n = n - 1 end elseif tv == "table" then local l = #v @@ -280,6 +286,9 @@ do end elseif next(v) then tojsonpp(v,k,depth,level+1,0) + elseif i > 1 then + n = n - 1 + -- we don't know if we have a hash or string end elseif tv == "boolean" then if tk == "number" then @@ -297,6 +306,8 @@ do else t[n] = f_key_val_nop(depth,k) end + elseif i > 1 then + n = n - 1 end else if tk == "number" then @@ -306,6 +317,8 @@ do k = lpegmatch(escaper,k) or k n = n + 1 t[n] = f_key_val_null(depth,k) + elseif i > 1 then + n = n - 1 end end end @@ -440,4 +453,8 @@ end -- inspect(l) -- print(s==l.s) -return json +-- if not package.loaded.json then +-- package.loaded.json = json +-- end + +-- return json |