ConvertTo-JsonEx
SYNOPSIS
Converts objects to JSON with additional serialization options.
SYNTAX
ConvertTo-JsonEx [-InputObject] <Object> [-Depth <Int32>] [-Compress] [-EnumsAsStrings] [-AsArray]
[<CommonParameters>]DESCRIPTION
Serializes one or more input objects to JSON. This cmdlet extends the default conversion behavior with explicit array output, optional enum-to-string conversion, configurable depth, and compressed formatting.
EXAMPLES
Example 1
PS C:\> Get-Process | Select-Object -First 1 | ConvertTo-JsonEx -Depth 3 -EnumsAsStringsConverts the first process object to formatted JSON and emits enum values as strings.
PARAMETERS
-AsArray
Wraps the JSON output in array brackets even when only a single input object is provided.
-Compress
Outputs minified JSON without indentation or extra whitespace.
-Depth
Specifies how many levels of nested objects are included during serialization.
-EnumsAsStrings
Serializes enum values by name instead of by their numeric value.
-InputObject
Specifies the object to serialize to JSON.
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -Verbose, -WarningAction, -WarningVariable, and -ProgressAction. For more information, see about_CommonParameters.
INPUTS
System.Object
OUTPUTS
System.Object
NOTES
RELATED LINKS
Last updated
Was this helpful?