
On Wed, Dec 17, 2014 at 09:59:10AM +0100, Wojtek NarczyĆski wrote:
On 17.12.2014 00:12, Richard A. O'Keefe wrote:
So if you depend on the order of the name/value pairs in a JSON object, you doing something surpassing strange and risky. All I wanted to do was to keep the order of key-value pairs in accordance with the order of fields in their corresponding haskell records, during serialization. I guess that would be okay.
It would still be problematic if you rely on this order to come back unchanged after putting your JSON through any processing. For example, if you have a JSON document like this: { "foo":23, "bar":"$quux" } ...and you pipe it through a Ruby script that walks through it and substitutes some value (say 42) wherever you have "$quux", you must be prepared to receive it back as: { "bar":42, "foo":23 } It is perfectly acceptable for your own processor to keep the ordering intact, but you cannot expect anything else to do the same for you. It also means that you cannot use Aeson to parse or represent your JSON, because it uses HashMaps to store objects, and those are by definition unordered containers.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Tobias Dammers - tobias@twokings.nl - 070-3457628 - www.twokings.nl Maandag t/m donderdag van 9.00 tot 17.30 Voor dringende vragen, mail naar support@twokings.nl