-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
ConvertFrom-Json -AsHashtable
now uses ordered hashtable
#9039
Labels
area-utility
Area - Microsoft.PowerShell.Utility module
issue-doc-idea
Issue - request for new content
Milestone
Comments
michaeltlombardi
added a commit
to michaeltlombardi/PowerShell-Docs
that referenced
this issue
Jul 19, 2022
Prior to this change, the `ConvertFrom-Json` cmdlet returnedd a **Hashtable** object when used with the **AsHashtable** parameter. Starting with PowerShell 7.3, it instead returns an **OrderedHashtable** object. This change: - Modifies the output type and parameter documentation to reflect the updated object type for 7.3. - Resolves MicrosoftDocs#9039 - Fixes AB#4440
4 tasks
michaeltlombardi
added a commit
to michaeltlombardi/PowerShell-Docs
that referenced
this issue
Jul 19, 2022
Prior to this change, the `ConvertFrom-Json` cmdlet returnedd a **Hashtable** object when used with the **AsHashtable** parameter. Starting with PowerShell 7.3, it instead returns an **OrderedHashtable** object. This change: - Modifies the output type and parameter documentation to reflect the updated object type for 7.3. - Updates the parameter documentation for 7.0+ to better reflect the reasons to use the **AsHashtable** parameter. - Resolves MicrosoftDocs#9039 - Fixes AB#4440
sdwheeler
pushed a commit
that referenced
this issue
Jul 19, 2022
Prior to this change, the `ConvertFrom-Json` cmdlet returnedd a **Hashtable** object when used with the **AsHashtable** parameter. Starting with PowerShell 7.3, it instead returns an **OrderedHashtable** object. This change: - Modifies the output type and parameter documentation to reflect the updated object type for 7.3. - Updates the parameter documentation for 7.0+ to better reflect the reasons to use the **AsHashtable** parameter. - Resolves #9039 - Fixes AB#4440
@sdwheeler, can the user choose whether they want the hashtable ordered or not? I'd like to be able to specify it in case this default ever changes. |
@RokeJulianLockhart No. There is no option for that in the cmdlet. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area-utility
Area - Microsoft.PowerShell.Utility module
issue-doc-idea
Issue - request for new content
Prerequisites
Get-Foo
cmdlet" instead of "New cmdlet."Summary
JSON typically has ordering to make it easier to read. Currently, a Hashtable does not preserve ordering so for complex JSON, the members are not where you would expect in terms of order. This change wraps OrderedDictionary into a OrderedHashtable that derives from Hashtable. This preserves existing compatibility with scripts that expect a Hashtable to be returned, but preserves the order of elements.
Details
No response
Articles
Related Source Pull Requests
ConvertFrom-Json -AsHashtable
to use ordered hashtable PowerShell/PowerShell#17405Related Source Issues
The text was updated successfully, but these errors were encountered: