Syntax error How to convert the hashtable to the JSON format using PowerShell?

How to convert the hashtable to the JSON format using PowerShell?



To convert the hashtable to the JSON format we can use the ConvertTo-Json command. First, we have the following hashtable,

Example

$Body = [PSCustomObject]@{
   AppName = 'StorageXIO'
   AppID ='xo2ss-12233-2nn12'
   License = 'valid'
}

To convert the hashtable to the JSON format,

$Body | ConvertTo-Json

Once you run the above command, properties are converted to the JSON format.

Output

{
   "AppName": "StorageXIO",
   "AppID": "xo2ss-12233-2nn12",
   "License": "valid"
}
Updated on: 2020-11-02T11:00:16+05:30

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements