From 838ef3fa57c5aa46681fedf263f08f33a02fdab9 Mon Sep 17 00:00:00 2001 From: Paul Hilchey Date: Sat, 24 May 2025 23:49:44 -0700 Subject: [PATCH 1/3] Document AsStream parameter --- .../ConvertTo-Json.md | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/reference/7.6/Microsoft.PowerShell.Utility/ConvertTo-Json.md b/reference/7.6/Microsoft.PowerShell.Utility/ConvertTo-Json.md index f99c04183d81..c1df86b1a323 100644 --- a/reference/7.6/Microsoft.PowerShell.Utility/ConvertTo-Json.md +++ b/reference/7.6/Microsoft.PowerShell.Utility/ConvertTo-Json.md @@ -15,9 +15,24 @@ Converts an object to a JSON-formatted string. ## SYNTAX +### Default (Default) ``` ConvertTo-Json [-InputObject] [-Depth ] [-Compress] - [-EnumsAsStrings] [-AsArray] [-EscapeHandling ] + [-EnumsAsStrings] [-EscapeHandling ] + [] +``` + +### Array +``` +ConvertTo-Json [-InputObject] -AsArray [-Depth ] [-Compress] + [-EnumsAsStrings] [-EscapeHandling ] + [] +``` + +### Stream +``` +ConvertTo-Json [-InputObject] -AsStream [-Depth ] [-Compress] + [-EnumsAsStrings] [-EscapeHandling ] [] ``` @@ -180,7 +195,23 @@ Outputs the object in array brackets, even if the input is a single object. ```yaml Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) +Parameter Sets: Array +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -AsStream + +Converts each input object to a complete JSON string. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: Stream Aliases: Required: False @@ -304,7 +335,8 @@ You can pipe any object to this cmdlet. ### System.String -This cmdlet returns a string representing the input object converted to a JSON string. +This cmdlet returns a string representing the input object(s) converted to a JSON string. +When AsStream is specified, each object is converted to a complete JSON string. ## NOTES From 60c672e1e3fd911a97dea2d1b15302c9052d3c94 Mon Sep 17 00:00:00 2001 From: Paul Hilchey Date: Sat, 24 May 2025 23:49:46 -0700 Subject: [PATCH 2/3] Document AsStream parameter From 22f3a90da466b716631781ee327f800386e16eda Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Thu, 4 Dec 2025 14:54:31 -0600 Subject: [PATCH 3/3] Rebase and minor edits --- .../ConvertTo-Json.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/reference/7.6/Microsoft.PowerShell.Utility/ConvertTo-Json.md b/reference/7.6/Microsoft.PowerShell.Utility/ConvertTo-Json.md index c1df86b1a323..3a295a2f0dcc 100644 --- a/reference/7.6/Microsoft.PowerShell.Utility/ConvertTo-Json.md +++ b/reference/7.6/Microsoft.PowerShell.Utility/ConvertTo-Json.md @@ -2,7 +2,7 @@ external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility -ms.date: 05/16/2024 +ms.date: 12/04/2025 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/convertto-json?view=powershell-7.6&WT.mc_id=ps-gethelp schema: 2.0.0 title: ConvertTo-Json @@ -11,11 +11,13 @@ title: ConvertTo-Json # ConvertTo-Json ## SYNOPSIS + Converts an object to a JSON-formatted string. ## SYNTAX ### Default (Default) + ``` ConvertTo-Json [-InputObject] [-Depth ] [-Compress] [-EnumsAsStrings] [-EscapeHandling ] @@ -23,6 +25,7 @@ ConvertTo-Json [-InputObject] [-Depth ] [-Compress] ``` ### Array + ``` ConvertTo-Json [-InputObject] -AsArray [-Depth ] [-Compress] [-EnumsAsStrings] [-EscapeHandling ] @@ -30,6 +33,7 @@ ConvertTo-Json [-InputObject] -AsArray [-Depth ] [-Compress] ``` ### Stream + ``` ConvertTo-Json [-InputObject] -AsStream [-Depth ] [-Compress] [-EnumsAsStrings] [-EscapeHandling ] @@ -53,8 +57,8 @@ object, which is easily managed in PowerShell. Many web sites use JSON instead of XML to serialize data for communication between servers and web-based apps. -As of PowerShell 7.1, `ConvertTo-Json` emits a warning if the depth of the input object exceeds -the depth specified for the command. This prevents unwanted data loss when converting objects. +As of PowerShell 7.1, `ConvertTo-Json` emits a warning if the depth of the input object exceeds the +depth specified for the command. This prevents unwanted data loss when converting objects. As of PowerShell 7.5-preview.3, `ConvertTo-Json` can serialize **BigInteger** values as raw JSON numbers. @@ -207,7 +211,8 @@ Accept wildcard characters: False ### -AsStream -Converts each input object to a complete JSON string. +Converts each input object to a separate, complete JSON object string, rather than combining all +input objects into a single JSON array. ```yaml Type: System.Management.Automation.SwitchParameter @@ -223,7 +228,7 @@ Accept wildcard characters: False ### -Compress -Omits white space and indented formatting in the output string. +Omits whitespace and indented formatting in the output string. ```yaml Type: System.Management.Automation.SwitchParameter