Skip to content

Commit 6158d4b

Browse files
HHHartmannmarcoskirsch
authored andcommitted
support changes json API (#116)
use sjson instead of cjson Also take care of backward compatibility before 2.1
1 parent c67ed16 commit 6158d4b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

httpserver-request.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ local function getRequestData(payload)
4646
local requestData
4747
return function ()
4848
--print("Getting Request Data")
49+
-- for backward compatibility before v2.1
50+
if (sjson == nil) then
51+
sjson = cjson
52+
end
4953
if requestData then
5054
return requestData
5155
else
@@ -60,7 +64,7 @@ local function getRequestData(payload)
6064
--print("body = [" .. body .. "]")
6165
if mimeType == "application/json" then
6266
--print("JSON: " .. body)
63-
requestData = cjson.decode(body)
67+
requestData = sjson.decode(body)
6468
elseif mimeType == "application/x-www-form-urlencoded" then
6569
requestData = parseFormData(body)
6670
else

0 commit comments

Comments
 (0)