Lines Matching refs:val
32 local function encode_nil(val)
37 local function encode_table(val, stack)
42 if stack[val] then error("circular reference") end
44 stack[val] = true
46 if rawget(val, 1) ~= nil or next(val) == nil then
49 for k in pairs(val) do
55 if n ~= #val then
59 for i, v in ipairs(val) do
62 stack[val] = nil
67 for k, v in pairs(val) do
73 stack[val] = nil
79 local function encode_string(val)
80 return '"' .. val:gsub('[%z\1-\31\\"]', escape_char) .. '"'
84 local function encode_number(val)
86 if val ~= val or val <= -math.huge or val >= math.huge then
87 error("unexpected number value '" .. tostring(val) .. "'")
89 return string.format("%.14g", val)
102 encode = function(val, stack)
103 local t = type(val)
106 return f(val, stack)
112 function json.encode(val)
113 return ( encode(val) )
289 local key, val
308 val, i = parse(str, i)
310 res[key] = val