lua-cjson icon indicating copy to clipboard operation
lua-cjson copied to clipboard

cjson的encode后的字符的顺序问题

Open KevinZXD opened this issue 5 years ago • 1 comments

有如下代码: location /echo1 { content_by_lua ' local tb = {y=123,b=234,c=456} local cjson = require "cjson" local out = cjson.encode(tb) ngx.say(out) '; }

访问http://xxx/echo1会输出; {"y":123,"c":456,"b":234}

如何按原来的{"y":123,"b":234,"c":456} 输出?我知道hash table都是无序或者说是顺序不确定的,如何实现我上述需求?

KevinZXD avatar Jan 14 '21 13:01 KevinZXD

Use json array instead.

ProgramForFun avatar Mar 12 '22 06:03 ProgramForFun