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

Add option to sort Yaml/Json object keys #819

Open
ArmaanMcleod opened this issue Oct 5, 2021 · 2 comments
Open

Add option to sort Yaml/Json object keys #819

ArmaanMcleod opened this issue Oct 5, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@ArmaanMcleod
Copy link
Contributor

Add an output option to sort object keys.

Currently all JSON/YAML keys are sorted when serialized. In most cases this is ideal, but we should have an option like output.sortObjectKeys which allows the user to disable auto key sorting.

For example:

Sort object keys (default to true)

output:
  sortObjectKeys: true

Disable sorting of object keys

output:
  sortObjectKeys: false

Related to #817 (comment)

@ArmaanMcleod ArmaanMcleod added the enhancement New feature or request label Oct 5, 2021
@ArmaanMcleod ArmaanMcleod self-assigned this Oct 6, 2021
@ArmaanMcleod
Copy link
Contributor Author

ArmaanMcleod commented Oct 29, 2021

Will come back to this one. I think its not worth implementing given YAML serialization already exists for baselines which always output the same sorted order of keys. Having an option like this would give inconsistent results between resources.

I also don't really see a reason why someone would wan't to turn this off, except maybe for a performance increase of not sorting keys by default with OrderBy() in the contract resolvers/type inspectors.

It would probably be more useful to allow the user to override the ordering of properties via an output option, but that is another issue 😄

@ArmaanMcleod ArmaanMcleod removed their assignment Oct 29, 2021
@BernieWhite
Copy link
Member

@ArmaanMcleod Sure. Let's park it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants