From 6158d4b5bac68332d24acbedad214150788c3b8e Mon Sep 17 00:00:00 2001 From: Gregor Hartmann Date: Mon, 2 Oct 2017 18:13:39 +0200 Subject: [PATCH] support changes json API (#116) use sjson instead of cjson Also take care of backward compatibility before 2.1 --- httpserver-request.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/httpserver-request.lua b/httpserver-request.lua index c6414da..3a7d56b 100644 --- a/httpserver-request.lua +++ b/httpserver-request.lua @@ -46,6 +46,10 @@ local function getRequestData(payload) local requestData return function () --print("Getting Request Data") + -- for backward compatibility before v2.1 + if (sjson == nil) then + sjson = cjson + end if requestData then return requestData else @@ -60,7 +64,7 @@ local function getRequestData(payload) --print("body = [" .. body .. "]") if mimeType == "application/json" then --print("JSON: " .. body) - requestData = cjson.decode(body) + requestData = sjson.decode(body) elseif mimeType == "application/x-www-form-urlencoded" then requestData = parseFormData(body) else