Title: `ConvertFrom-Json -AsHashtable` isn't consistently ordered · Issue #26009 · PowerShell/PowerShell · GitHub
Open Graph Title: `ConvertFrom-Json -AsHashtable` isn't consistently ordered · Issue #26009 · PowerShell/PowerShell
X Title: `ConvertFrom-Json -AsHashtable` isn't consistently ordered · Issue #26009 · PowerShell/PowerShell
Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerShell 5.1 and PowerShell. Steps to reprodu...
Open Graph Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
X Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/26009
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`ConvertFrom-Json -AsHashtable` isn't consistently ordered","articleBody":"### Prerequisites\n\n- [x] Write a descriptive title.\n- [x] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\n- [x] Search the existing issues.\n- [x] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\n- [x] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://learn.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\n\n### Steps to reproduce\n\n1.) Have a JSON with multiple keys in an object\n2.) Convert to pwsh objects by using `ConvertFrom-Json -AsHashtable`\n\nA random order appears even on pwsh 7.3+\n\n### Expected behavior\n\n```console\nThe ordering should be the same always\n```\n\n### Actual behavior\n\n```console\nRandom order appears on subsequent runs\n```\n\n### Error details\n\n```console\nN/A - Crashes Pester Tests as Expected doesn't match half of the time\n```\n\n### Environment data\n\n```powershell\nImage: mcr.microsoft.com/dotnet/sdk:9.0\n\nPS /> $PSVersionTable\n\nName Value\n---- -----\nPSVersion 7.5.2\nPSEdition Core\nGitCommitId 7.5.2\nOS Debian GNU/Linux 12 (bookworm)\nPlatform Unix\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\nPSRemotingProtocolVersion 2.3\nSerializationVersion 1.1.0.1\nWSManStackVersion 3.0\n```\n\n### Visuals\n\nOn two different runs of the tests (dumping out the object converted back to JSON):\n\n\u003cimg width=\"1670\" height=\"173\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/4b83b590-004c-4548-8e45-34e6b6e88df1\" />\n\n\n\nOne can see it's an OrderedHashtable but the ordering within it is totally random...\n\nOne run:\n```\nName Value\n---- -----\naws:SourceAccount \u003cID>\naws:SourceArn \u003cARN>\n\n\nIsPublic IsSerial Name BaseType\n-------- -------- ---- --------\nTrue False OrderedHashtable System.Collections.H…\n```\n\nAnother run:\n```\n\nName Value\n---- -----\naws:SourceArn \u003cARN>\naws:SourceAccount \u003cID>\n\n\nIsPublic IsSerial Name BaseType\n-------- -------- ---- --------\nTrue False OrderedHashtable System.Collections.H…\n```\n\nSince 7.3+ this should be a properly ordered Hashtable with a determined order:\nIssue: https://github.com/PowerShell/PowerShell/issues/17404\nPR: https://github.com/PowerShell/PowerShell/pull/17405","author":{"url":"https://github.com/ElvenSpellmaker","@type":"Person","name":"ElvenSpellmaker"},"datePublished":"2025-09-08T09:55:11Z","url":"https://github.com/PowerShell/PowerShell/issues/26009"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a3a42850-2bcc-f788-cfc5-d76311e6af74 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9DBA:231929:1E5E28:2A152E:6AFD9214 |
| html-safe-nonce | 0d6f420330f8a24e1ea7892e277cc039e715b7551c99522c5abe559ef2418b37 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5REJBOjIzMTkyOToxRTVFMjg6MkExNTJFOjZBRkQ5MjE0IiwidmlzaXRvcl9pZCI6IjUxOTUzODc3NDgwODQ0NTM5MDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0e33d1c0b05949eac745b3e9672f1b35b356706774463c03fd1a86d0d7ca9cdb |
| hovercard-subject-tag | issue:3393479748 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/26009/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8aa52eb3e2c77a9c93ce14ea812595a8b3e911ddf7875d9f30f6a13ecc4d2be2/PowerShell/PowerShell/issues/26009 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8aa52eb3e2c77a9c93ce14ea812595a8b3e911ddf7875d9f30f6a13ecc4d2be2/PowerShell/PowerShell/issues/26009 |
| og:image:alt | Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ElvenSpellmaker |
| hostname | github.com |
| expected-hostname | github.com |
| None | bc86424ef34a73b386237872800e922d149d65ba907f63d6f150a2dcb8433bea |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 927a6c5ab1c32b38830f1b9d3050c0b9e9aa92e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width