Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ConvertFrom-Json should have a -AsOrderedDictionary #17404

Copy link
Copy link
@SteveL-MSFT

Description

@SteveL-MSFT
Issue body actions

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.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.