local post_data = ngx.req.get_body_data()
    --[[ngx.log(ngx.ERR, 'post data:', post_data)]]

    local ok, res_tab = pcall(cjson.decode, post_data)
    if not ok then 
        ngx.log(ngx.ERR, 'post data is not json!', post_data)
        get_respone(Result_Code.Error)
        return
    end

    -- 真正判断是否json
    post_data = string.gsub(post_data,"\"{","{")
    post_data = string.gsub(post_data,"}\"","}")
    post_data = string.gsub(post_data,"\\","")
    local ok, res_tab = pcall(cjson.decode, post_data)
    if not ok then 
        ngx.log(ngx.ERR, 'post data is not json!', post_data)
        get_respone(Result_Code.Error)
        return
    end

 

posted on 2015-08-13 15:18  凌度  阅读(1780)  评论(0编辑  收藏  举报