0

I have a JWT that i am decoding and printing to my log, but the problem is when i do that it is also including the "" which i do not want ...

Here is the snippet of my code that is doing the work for me

local jwt = require "resty.jwt"
local jwt_obj = jwt:load_jwt(res.access_token)
local cjson = require "cjson"
ngx.log(ngx.DEBUG, "res.access_token.sub=", cjson.encode(jwt_obj.payload.sub) 

So in my log that then looks like this

2018/03/24 19:19:16 [debug] 13683#13683: *1 [lua] access_by_lua(default.conf:82):30: res.access_token.sub="yesyesyes"

So i want to remove the "" from around the yesyesyes

  • It looks like `jwt_obj.payload.sub` is a string. If you don't JSON-encode it but just concatenate it, the quotes will not be added. – cyclaminist Mar 31 '18 at 20:33

1 Answers1

0

Good spot .. Resolved with the below

local jwt = require "resty.jwt"
local jwt_obj = jwt:load_jwt(res.access_token)
local cjson = require "cjson"
ngx.log(ngx.DEBUG, "res.access_token.sub=", jwt_obj.payload.sub)