mod_storage_sql: Use util.json instead of util.serialization.
authorWaqas Hussain <waqas20@gmail.com>
Mon, 27 Dec 2010 14:43:57 +0000 (19:43 +0500)
committerWaqas Hussain <waqas20@gmail.com>
Mon, 27 Dec 2010 14:43:57 +0000 (19:43 +0500)
plugins/mod_storage_sql.lua

index 7508072621e55a7079f2576ce2bb839748767334..53f1ea0a47602508d6594011897d8c509ffb5ca9 100644 (file)
@@ -25,7 +25,7 @@ local tonumber = tonumber;
 local pairs = pairs;
 local next = next;
 local setmetatable = setmetatable;
-local json = { stringify = function(s) return require"util.serialization".serialize(s) end, parse = require"util.serialization".deserialize };
+local json = require "util.json";
 
 local connection = ...;
 local host,user,store = module.host;
@@ -59,7 +59,7 @@ do -- process options to get a db connection
                        module:log("debug", "Initialized new SQLite3 database");
                end
                assert(connection:commit());
-               --print("===", json.stringify())
+               --print("===", json.encode())
        end
 end
 
@@ -68,7 +68,7 @@ local function serialize(value)
        if t == "string" or t == "boolean" or t == "number" then
                return t, tostring(value);
        elseif t == "table" then
-               local value,err = json.stringify(value);
+               local value,err = json.encode(value);
                if value then return "json", value; end
                return nil, err;
        end
@@ -81,7 +81,7 @@ local function deserialize(t, value)
                elseif value == "false" then return false; end
        elseif t == "number" then return tonumber(value);
        elseif t == "json" then
-               return json.parse(value);
+               return json.decode(value);
        end
 end