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 -AsHashtable isn't consistently ordered #26009

Copy link
Copy link
@ElvenSpellmaker

Description

@ElvenSpellmaker
Issue body actions

Prerequisites

Steps to reproduce

1.) Have a JSON with multiple keys in an object
2.) Convert to pwsh objects by using ConvertFrom-Json -AsHashtable

A random order appears even on pwsh 7.3+

Expected behavior

The ordering should be the same always

Actual behavior

Random order appears on subsequent runs

Error details

N/A - Crashes Pester Tests as Expected doesn't match half of the time

Environment data

Image:  mcr.microsoft.com/dotnet/sdk:9.0

PS /> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.5.2
PSEdition                      Core
GitCommitId                    7.5.2
OS                             Debian GNU/Linux 12 (bookworm)
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

On two different runs of the tests (dumping out the object converted back to JSON):

Image

One can see it's an OrderedHashtable but the ordering within it is totally random...

One run:

Name                           Value
----                           -----
aws:SourceAccount              <ID>
aws:SourceArn                  <ARN>


IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     False    OrderedHashtable                         System.Collections.H…

Another run:


Name                           Value
----                           -----
aws:SourceArn                  <ARN>
aws:SourceAccount              <ID>


IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     False    OrderedHashtable                         System.Collections.H…

Since 7.3+ this should be a properly ordered Hashtable with a determined order:
Issue: #17404
PR: #17405

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-AnsweredThe question is answered.The question is answered.

    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.