Skip to content

Breaking change in PS 7.3.0: ConvertFrom-Json -AsHashTable #18524

Description

@alexbuckgit

Prerequisites

Steps to reproduce

Because the return type of ConvertFrom-Json -AsHashTable changed from [HashTable] to [OrderedHashtable], any code explicitly checking that the return type equals [Hashtable] using -eq (rather than -is) will likely break.

To avoid breaking existing code, consider reverting -AsHashtable functionality to return a [Hashtable] and adding a separate switch for -AsOrderedHashtable.

Expected behavior

> ('{ "name": "Id", "value": 1 }' | ConvertFrom-Json -AsHashTable).GetType() -eq [Hashtable]
True

Actual behavior

> ('{ "name": "Id", "value": 1 }' | ConvertFrom-Json -AsHashTable).GetType() -eq [Hashtable]
False

Error details

No response

Environment data

Name                           Value
----                           -----
PSVersion                      7.3.0
PSEdition                      Core
GitCommitId                    7.3.0
OS                             Microsoft Windows 10.0.22000
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions