projects
/
prosody.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge 0.10->trunk
[prosody.git]
/
util
/
json.lua
diff --git
a/util/json.lua
b/util/json.lua
index a8a58afcd12062267cf63414d905e9d6c75c75bc..2c598446bab233d05825b7926bd21a7bd29d7b19 100644
(file)
--- a/
util/json.lua
+++ b/
util/json.lua
@@
-13,7
+13,7
@@
local tostring, tonumber = tostring, tonumber;
local pairs, ipairs = pairs, ipairs;
local next = next;
local error = error;
local pairs, ipairs = pairs, ipairs;
local next = next;
local error = error;
-local
newproxy, getmetatable, setmetatable = newproxy,
getmetatable, setmetatable;
+local
getmetatable, setmetatable =
getmetatable, setmetatable;
local print = print;
local has_array, array = pcall(require, "util.array");
local print = print;
local has_array, array = pcall(require, "util.array");
@@
-22,10
+22,7
@@
local array_mt = has_array and getmetatable(array()) or {};
--module("json")
local json = {};
--module("json")
local json = {};
-local null = newproxy and newproxy(true) or {};
-if getmetatable and getmetatable(null) then
- getmetatable(null).__tostring = function() return "null"; end;
-end
+local null = setmetatable({}, { __tostring = function() return "null"; end; });
json.null = null;
local escapes = {
json.null = null;
local escapes = {
@@
-148,7
+145,9
@@
end
function simplesave(o, buffer)
local t = type(o);
function simplesave(o, buffer)
local t = type(o);
- if t == "number" then
+ if o == null then
+ t_insert(buffer, "null");
+ elseif t == "number" then
t_insert(buffer, tostring(o));
elseif t == "string" then
stringsave(o, buffer);
t_insert(buffer, tostring(o));
elseif t == "string" then
stringsave(o, buffer);