Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

sorting option confusing #3

clinty opened this Issue Jan 4, 2014 · 3 comments


None yet
2 participants

clinty commented Jan 4, 2014

There is a Debian bug report about the behavior of aeson-pretty -s.

The problem is that the json' parser is returning the keys to aeson-pretty already sorted.


informatikr commented Jan 5, 2014

Hello clinty, thanks for the report.

When you say

the json' parser is returning the keys to aeson-pretty already sorted

do you mean "sorted" (e.g. alphabetically) or "reordered" (compared to the input data)?

"Reordering” is expected, because 'aeson' represents JSON objects as Hashmaps, so the ordering information is lost. I don't think there is a workaround, but I could probably document that behavior in some way.

I can not reproduce a "sorting" problem on my system, but if the error is actually sorting of the keys: Which version of the 'haskell-platform', 'aeson' and 'unordered-containers' packages are you using?


clinty commented Jan 5, 2014

This illustrates the example from the original complainant:

Prelude Data.Aeson Data.Attoparsec.Lazy Data.String> parse json' (fromString "{"b":1,"a":1}")
Done "" Object fromList [("a",Number 1),("b",Number 1)]

If I change that to parse json' (fromString "{"d":1,"c":1,"b":1,"a":1}") then it is clearly reordered, and not sorted, as you say.

You can see the relevant versions in the "unstable" column at http://people.debian.org/~nomeata/platform.html and aeson is .


informatikr commented Jan 5, 2014

Version 0.7.1 on Hackage has a little added documentation in the help message to hopefully clarify the issue.

Thanks again for the report, please let me know if you find any other problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment