mpx / lua-cjson

Lua CJSON is a fast JSON encoding/parsing module for Lua
https://kyne.au/~mark/software/lua-cjson.php
MIT License
924 stars 474 forks source link

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

Open KevinZXD opened 3 years ago

KevinZXD commented 3 years ago

有如下代码: 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都是无序或者说是顺序不确定的,如何实现我上述需求?

ProgramForFun commented 2 years ago

Use json array instead.