Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
JSON encode/decode out of order — Gideros Forum

JSON encode/decode out of order

andrecaribeandrecaribe Member
edited October 2013 in Plugins
When I try to read a json file and I use Json.Encode/Json.Decode (or json.encode/json.decode) my output is an valid json, with all attributes, but out of order. Example:

Code:
local f = io.open("|R|settings.json", "r")
local data = f:read("*all")
local json = Json.Decode(data)
f:close()
print(Json.Encode(json.user))
Input:
"user": {
"name": "",
"email": "",
"voucher": "",
"tickets": 1,
"facebookLike": false,
"wizardStudent": false,
"counter": {"acertadas": 0, "total": 200}
}

Output:
{"voucher":"","wizardStudent":false,"name":"","counter":{"acertadas":0,"total":200},"facebookLike":false,"tickets":1,"email":""}

Why this is important?
I need to generate an hash code (SHA1 + salt) with this data in App and server. If the order of the data is different, the SHA1 will never match. I have no idea what causes the disorder, apparently the code json.lua has nothing to do it.

@ar2rsawseen, have any idea??

Comments

Sign In or Register to comment.