[Haskell-cafe] Ordered JSON objects?
Steve Schafer
steve at fenestra.com
Mon Dec 15 19:54:37 UTC 2014
On Mon, 15 Dec 2014 20:32:20 +0100, you wrote:
>Anyway, one thing I'm running up against is that I am going to need
>ordered key/value collections, which I believe is something JSON does
>not support out-of-the-box: "objects" ({"foo":15, "bar":23}) are
>conceptually unordered key/value collections (and Aeson treats them as
>such, using hash maps as the intermediate storage format), so I lose
>ordering; OTOH, flat lists ([15, 23]) do not have keys, and lists of
>"pairs" (two-element lists) produce uglier syntax ([["foo",15],
>["bar",23]]), but they are the "correct" solution.
I think this:
[{"foo":15}, {"bar":23}]
makes more sense than this:
[["foo", 15], ["bar", 23]]
as it maintains the key vs. value distinction.
But you are correct that in JSON, arrays are ordered but objects are
not.
-Steve Schafer
More information about the Haskell-Cafe
mailing list