Summary of the new feature / enhancement
Currently, when using ConvertFrom-Json -AsHashtable, you get an unordered hashtable where the properties don't match the order defined in the JSON.
'{ "a": 0, "b": 1, "c": 2 }' | ConvertFrom-Json -AsHashtable
Expected:
Name Value
---- -----
a 0
b 1
c 2
Actual:
Name Value
---- -----
c 2
b 1
a 0
Proposed technical implementation details (optional)
Proposal is to make -AsHashtable actually return an OrderedDictionary. I believe from PS script usage, there should not be any impact even if the type changes. Alternative would be to add a -Ordered switch used with -AsHashtable or a -AsOrderedDictionary in a different parameterset from -AsHashtable but this seems unnecessary and most of the time, I would expect users converting from JSON would want to preserve order making it more readable.
Summary of the new feature / enhancement
Currently, when using
ConvertFrom-Json -AsHashtable, you get an unordered hashtable where the properties don't match the order defined in the JSON.Expected:
Actual:
Proposed technical implementation details (optional)
Proposal is to make
-AsHashtableactually return an OrderedDictionary. I believe from PS script usage, there should not be any impact even if the type changes. Alternative would be to add a-Orderedswitch used with-AsHashtableor a-AsOrderedDictionaryin a different parameterset from-AsHashtablebut this seems unnecessary and most of the time, I would expect users converting from JSON would want to preserve order making it more readable.