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

ConvertFrom-Json -AsHashtable now uses ordered hashtable #9039

Closed
2 tasks done
sdwheeler opened this issue Jul 19, 2022 · 2 comments · Fixed by #9042
Closed
2 tasks done

ConvertFrom-Json -AsHashtable now uses ordered hashtable #9039

sdwheeler opened this issue Jul 19, 2022 · 2 comments · Fixed by #9042
Assignees
Labels
area-utility Area - Microsoft.PowerShell.Utility module issue-doc-idea Issue - request for new content
Milestone

Comments

@sdwheeler
Copy link
Contributor

Prerequisites

  • Existing Issue: Search the existing issues for this repository. If there is an issue that fits your needs do not file a new one. Subscribe, react, or comment on that issue instead.
  • Descriptive Title: Write the title for this issue as a short synopsis. If possible, provide context. For example, "Document new 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

  • reference/7.3/Microsoft.PowerShell.Utility/ConvertFrom-Json

Related Source Pull Requests

Related Source Issues

@sdwheeler sdwheeler added area-utility Area - Microsoft.PowerShell.Utility module issue-doc-idea Issue - request for new content labels Jul 19, 2022
@sdwheeler sdwheeler added this to the 7.3.0 milestone Jul 19, 2022
@michaeltlombardi michaeltlombardi self-assigned this Jul 19, 2022
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
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 sdwheeler modified the milestones: 7.3, 7.3-p6 Sep 21, 2022
@RokeJulianLockhart
Copy link
Contributor

RokeJulianLockhart commented Dec 16, 2023

#9039 (comment)

@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.

@sdwheeler
Copy link
Contributor Author

@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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants