As a Roblox developer, it is currently too hard to enforce an order in the returned value of HttpService:JSONEncode()
. Consider this example:
I have two nesting dictionaries, originating from different places, but who are deeply equal to one another. Putting both tables through JSONEncode()
spits out these two values:
Dictionary 1:
{"Assets":[{"Id":27112025,"Name":"Roblox 2.0 Torso","AssetType":{"Id":27,"Name":"Torso"}}
…
Dictionary 2:
{"BodyColors":{"HeadColor":"0.80,0.56,0.41","TorsoColor":"0.80,0.56,0.41","LeftArmColor":"0.80,0.56,0.41","RightLegColor":"0.80,0.56,0.41"
…
We can already see that there is conflicting ordering in the two dictionaries. This behavior propagates further into any nested dictionaries, making this problem recursively more difficult to solve. If the dictionaries are equals (the data in these dictionaries contains only primitive data), then they should always return the same encoded string.
The idea here is to leverage the encoded unique JSON to then create an MD5 hash that describes an outfit created by a player in our game. As far as I know, Roblox does this on the website by creating MD5 hashes that describe the Players’ outfits for thumbnails for a number of reasons, one of them being storage efficiency.
If Roblox is able to address this issue, it would improve my development experience, because I wouldn’t have to cut up, parse, and reconstruct the nested JSON alphabetically.
I’m not suggesting that JSONEncode enforce alphabetical ordering necessarily, but some expectable pattern would be very valuable.