cjson

local json = require("cjson")

local data = {1, 2}
data[1] = 99


-- ... do the other things
ngx.say(json.encode(data))

ngx.say("value --> ", json.encode({dogs={}}))

local str  = '{"a": "b"}'
local value = json.decode(str)
ngx.say("decode:",value.a)


[99,2]
value --> {"dogs":{}}
decode:b

猜你喜欢

转载自xiangjie88.iteye.com/blog/2281011