Title: ConvertTo-Json outputs IPAddress as object instead of string, with inconsistent properties · Issue #26636 · PowerShell/PowerShell · GitHub
Open Graph Title: ConvertTo-Json outputs IPAddress as object instead of string, with inconsistent properties · Issue #26636 · PowerShell/PowerShell
X Title: ConvertTo-Json outputs IPAddress as object instead of string, with inconsistent properties · Issue #26636 · 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. Summary ConvertT...
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/26636
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ConvertTo-Json outputs IPAddress as object instead of string, with inconsistent properties","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### Summary\n\n`ConvertTo-Json` produces different JSON output for the same `IPAddress` value depending on whether it is passed via pipeline or via `-InputObject` parameter. The pipeline output includes an `IPAddressToString` property, while the `-InputObject` output does not.\n\n### Steps to reproduce\n\n```powershell\n$ip = [System.Net.IPAddress]::Parse(\"192.168.1.1\")\n\n# Via pipeline\n$ip | ConvertTo-Json -Compress\n\n# Via -InputObject parameter\nConvertTo-Json -InputObject $ip -Compress\n```\n\n### Expected behavior\n\n```console\n# Both methods should produce the same output\n\"192.168.1.1\"\n```\nNote: Serializing as a string would require a custom JsonConverter. Similar types (e.g., IPEndPoint, PhysicalAddress) would also need the same treatment, so the scope of this change may be larger than it appears.\n\n### Actual behavior\n\n```console\n# Via pipeline (includes IPAddressToString)\n{\"AddressFamily\":2,\"ScopeId\":null,\"IsIPv6Multicast\":false,\"IsIPv6LinkLocal\":false,\"IsIPv6SiteLocal\":false,\"IsIPv6Teredo\":false,\"IsIPv6UniqueLocal\":false,\"IsIPv4MappedToIPv6\":false,\"Address\":16885952,\"IPAddressToString\":\"192.168.1.1\"}\n\n# Via -InputObject (no IPAddressToString)\n{\"AddressFamily\":2,\"ScopeId\":null,\"IsIPv6Multicast\":false,\"IsIPv6LinkLocal\":false,\"IsIPv6SiteLocal\":false,\"IsIPv6Teredo\":false,\"IsIPv6UniqueLocal\":false,\"IsIPv4MappedToIPv6\":false,\"Address\":16885952}\n```\n\n### Environment data\n\n```powershell\nName Value\n---- -----\nPSVersion 7.5.1\nPSEdition Core\nGitCommitId 7.5.1\nOS Microsoft Windows 10.0.26100\nPlatform Win32NT\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\nPSRemotingProtocolVersion 2.3\nSerializationVersion 1.1.0.1\nWSManStackVersion 3.0\n```\n","author":{"url":"https://github.com/yotsuda","@type":"Person","name":"yotsuda"},"datePublished":"2025-12-21T23:52:37.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/26636/PowerShell/issues/26636"}
| 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:72f81239-d9c0-b2be-9956-3823df948f59 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A634:7FE64:21D5393:2C0E5B4:696472BF |
| html-safe-nonce | 47fe8b014955cb85ecce81d1eeecbcd96eda1be949ca4f19b29f84eaa96a0073 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjM0OjdGRTY0OjIxRDUzOTM6MkMwRTVCNDo2OTY0NzJCRiIsInZpc2l0b3JfaWQiOiI3NDE1MTQ0MzU2OTM1NjYwMjIzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 2a036a95482e3c1e92ffbc327c8b76f077d75dc74d8fcd35a07f6e81ec89289a |
| hovercard-subject-tag | issue:3751771411 |
| 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/26636/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bc45a853aad0b3a066ce8e1edae190f870f600673a5659201fdbfed54e184bf5/PowerShell/PowerShell/issues/26636 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bc45a853aad0b3a066ce8e1edae190f870f600673a5659201fdbfed54e184bf5/PowerShell/PowerShell/issues/26636 |
| 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 | yotsuda |
| hostname | github.com |
| expected-hostname | github.com |
| None | baa7d9900fdf7b27d604f36887af878d569cfbdcf97126832a5f4f0caf0c6ba5 |
| 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 | 842eff1d11f899d02b6b3b98fa3ea4860e64b34e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width