mpx / lua-cjson

Lua CJSON is a fast JSON encoding/parsing module for Lua

Home Page:https://kyne.au/~mark/software/lua-cjson.php

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

KevinZXD opened this issue · comments

commented

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

Use json array instead.