Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
KevinZXD opened this issue Jan 14, 2021 · 1 comment
Open

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

KevinZXD opened this issue Jan 14, 2021 · 1 comment

Comments

@KevinZXD
Copy link

有如下代码:
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
Copy link

Use json array instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants