Hướng dẫn dùng convertto-json JavaScript
Skip to main content This browser is no longer supported. Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
ConvertTo-Json
Converts an object to a JSON-formatted string. In this articleSyntax
DescriptionThe Note As of PowerShell 7.2, Extended Type System properties of DateTime and String objects are no longer serialized and only the simple object is converted to JSON format You can then use the Many web sites use JSON instead of XML to serialize data for communication between servers and web-based apps. As of PowerShell 7.1, This cmdlet was introduced in Windows PowerShell 3.0. ExamplesExample 1
This command uses the Example 2
This example shows the output from Example 3
This command shows the effect of using the Compress parameter of Example 4
This example uses the Example 5
This example shows how to use the ParametersOutputs the object in array brackets, even if the input is a single object.
Omits white space and indented formatting in the output string.
Specifies how many levels of contained objects are included in the JSON representation. The value can be any number from
Provides an alternative serialization option that converts all enumerations to their string representation.
Controls how certain characters are escaped in the resulting JSON output. By default, only control characters (like newline) are escaped. Acceptable values are:
This parameter was introduced in PowerShell 6.2.
Specifies the objects to convert to JSON format. Enter a variable that contains the objects, or type a command or expression that gets the objects. You can also pipe an object to The InputObject parameter is required, but its value can be null (
InputsObject You can pipe any object to OutputsString NotesThe
FeedbackSubmit and view feedback for |