Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve fields order in dhall-to-json #2158

Open
countoren opened this issue Mar 6, 2021 · 3 comments
Open

Preserve fields order in dhall-to-json #2158

countoren opened this issue Mar 6, 2021 · 3 comments

Comments

@countoren
Copy link

countoren commented Mar 6, 2021

It could be helpful to have dhall-to-json to maintain the field order of a Json object in dhall record sets(or some other alternative type) instead of having it order alphabetically.

some application might be effected by the fields order of a Json for example.
Or some user will order the field in a specific way in order for them to have the Json more readable (sub objects fields usually are pushed to the end).

this ticket is base on this topic in dhall discourse

@countoren countoren changed the title Preserve fields order in dhall-to-json Preserve fields order in dhall-to-json Mar 6, 2021
@Gabriella439
Copy link
Collaborator

It appears that this is a limitation of using the aeson package for decoding JSON, at least for decoding arbitrary JSON Values. The reason why is that the Value type used to represent schema-free JSON uses a HashMap to represent JSON objects and that representation does not preserve the key order.

So it looks like this might not be fixable without switching to another underlying package for working with JSON values.

@Gabriella439
Copy link
Collaborator

Oh, also, here is the relevant aeson issue discussing this limitation: haskell/aeson#368

@sjakobi
Copy link
Collaborator

sjakobi commented Mar 8, 2021

#1813 is related.

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

No branches or pull requests

3 participants