Open ArmaanMcleod opened 2 years ago
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 Sure. Let's park it for now.
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
)Disable sorting of object keys
Related to https://github.com/microsoft/PSRule/issues/817#issuecomment-933126658