aeson-pretty
aeson-pretty copied to clipboard
Option to preserve key order relying on toEncoding
Right now the keys are always resorted when using encodePretty
.
However, sometimes it is desired to preserve the key order from toEncoding
.
See https://github.com/GetShopTV/swagger2/issues/98 for a possible use case.
This would definitely a plus. Right now there are many cases where we cannot use encodePretty
(and use encode
from Data.Aeson
instead) because of this.
I'm interested by this issue.
Unfortunately, toEncoding
yields a Builder
which does not contain any structure anymore, so it is not possible to format it again, except by converting it back to Value
with decode
, but the order will be lost.
IMO this is a pretty serious issue that conflicts with this library's core mission:
The library provides a single function encodePretty. It is a drop-in replacement for aeson's encode function, producing JSON-ByteStrings for human readers.
@informatikr @DougBurke Would you be open to a PR that fixes this behaviour?
@theophile-scrive I've taken over maintainership for this package. I'd definitely be interested!
@martijnbastiaan Very well. :)