You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/05/07 04:14:59 UTC

[GitHub] [apisix] sniper-xx commented on issue #4193: request help: how to resovle cjson decode empty array and emtpy object separately?

sniper-xx commented on issue #4193:
URL: https://github.com/apache/apisix/issues/4193#issuecomment-834050995


   ```lua
   local function wrap_result(conf, ctx)
       local result = {
           msg="ok",
           code= resp_code,
           elapsed = ngx.time()-elapsed,
           data = "__placeholder__",
           success=true
       }
   
       --如果完成后台数据读取,重新进行Json结果封装
       result['data'] = cjson_decode(data_buffer)
       ngx.arg[1] = cjson_encode(result)
       --local wrap_string = cjson_encode(result)
       --local ret_content = ngx.re.sub(wrap_string,'"__placeholder__"',data_buffer,'jo')
       --ngx.arg[1] = ret_content
       ngx.arg[2] = true
   end
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org