Title: ConvertTo-Json unexpectedly serializes AutomationValue.Null as an empty object, not null · Issue #9231 · PowerShell/PowerShell · GitHub
Open Graph Title: ConvertTo-Json unexpectedly serializes AutomationValue.Null as an empty object, not null · Issue #9231 · PowerShell/PowerShell
X Title: ConvertTo-Json unexpectedly serializes AutomationValue.Null as an empty object, not null · Issue #9231 · PowerShell/PowerShell
Description: PowerShell commands that output nothing output the special [System.Management.Automation.Internal.AutomationNull]::Value singleton, which typically behaves like $null. Unexpectedly, ConvertTo-Json doesn't treat it as $null, but treats it...
Open Graph Description: PowerShell commands that output nothing output the special [System.Management.Automation.Internal.AutomationNull]::Value singleton, which typically behaves like $null. Unexpectedly, ConvertTo-Json ...
X Description: PowerShell commands that output nothing output the special [System.Management.Automation.Internal.AutomationNull]::Value singleton, which typically behaves like $null. Unexpectedly, ConvertTo-Json ...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/9231
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ConvertTo-Json unexpectedly serializes AutomationValue.Null as an empty object, not null","articleBody":"PowerShell commands that output nothing output the special `[System.Management.Automation.Internal.AutomationNull]::Value` singleton, which typically behaves like `$null`.\r\n\r\nUnexpectedly, `ConvertTo-Json` doesn't treat it as `$null`, but treats it as an _empty object_, which is undesired.\r\n\r\n# Steps to reproduce\r\n\r\n```powershell\r\n# Note: `. {}` yields the [System.Management.Automation.Internal.AutomationNull]::Value\r\n# singleton, not $null.\r\n[pscustomobject] @{ foo = . {}; bar = $null } | ConvertTo-Json\r\n```\r\n\r\n# Expected behavior\r\n\r\n```none\r\n{\r\n \"foo\": null,\r\n \"bar\": null\r\n}\r\n```\r\n\r\n# Actual behavior\r\n\r\n```none\r\n{\r\n \"foo\": {},\r\n \"bar\": null\r\n}\r\n```\r\n\r\n# Environment data\r\n\r\n```none\r\nPowerShell Core 6.2.0-rc.1\r\nWindows PowerShell v5.1 \r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2019-03-26T18:44:44Z","url":"https://github.com/PowerShell/PowerShell/issues/9231"}
| 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:f865704c-b8bb-8dc3-357d-9b7ead53325a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BBCE:139ADC:F5CEF:15DCAD:6AFD4C6A |
| html-safe-nonce | 094689ab1075b1234bfffe958a38f6c78e8b8b2faeda04dcf01de0e79ff5dd5d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQkNFOjEzOUFEQzpGNUNFRjoxNURDQUQ6NkFGRDRDNkEiLCJ2aXNpdG9yX2lkIjoiOTA3MDQ3NDMwMzg3ODU0ODU4NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | fcf475278629b89eee457a433357220908f6f5934a3e22064fb948f2cf897657 |
| hovercard-subject-tag | issue:425589660 |
| 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/9231/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c9ae89993b6a2cf87f6806502b90a820d6435bebb462683b3d51e91f189b2990/PowerShell/PowerShell/issues/9231 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c9ae89993b6a2cf87f6806502b90a820d6435bebb462683b3d51e91f189b2990/PowerShell/PowerShell/issues/9231 |
| og:image:alt | PowerShell commands that output nothing output the special [System.Management.Automation.Internal.AutomationNull]::Value singleton, which typically behaves like $null. Unexpectedly, ConvertTo-Json ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mklement0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 66653c2e55a6fff2930be1bdf07ee4f8aa137e3956d056c822563be6f878755e |
| 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 | b6f01f7cb9f35f8c09949773241a3d49dd04b340 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width