Convert a JSON-formatted string to a custom object.

      ConvertFrom-Json [-InputObject] String [CommonParameters]

   -InputObject String
        The JSON strings to convert to JSON objects. Enter a variable that contains the string, or type a 
        command or expression that gets the string. You can also pipe a string to ConvertFrom-Json .
        The -InputObject parameter is required, but its value can be an empty string.
        When the input object is an empty string, ConvertFrom-Json does not generate any output.

        The -InputObject value cannot be $Null.

Standard Aliases for ConvertFrom-Json: none, but if you want to add a short alias like cfjn, set it with set-alias

This cmdlet was introduced in Windows PowerShell 3.0.


Convert a DateTime object to a JSON object:

PS C:\> Get-Date | Select-Object -Property * | ConvertTo-Json | ConvertFrom-Json

This command uses the Select-Object cmdlet to get all of the properties of the DateTime object. It uses ConvertTo-Json to convert the DateTime object to a JSON-formatted string and ConvertFrom-Json to convert the JSON-formatted string to a JSON object. The object properties: Date, Day, Hour etc are then displayed on screen.

Get JSON strings from a web service and convert them to Windows PowerShell objects:

PS C:\> $j = Invoke-WebRequest -Uri | ConvertFrom-Json

“The price of anything is the amount of life you exchange for it” ~ Henry David Thoreau

Related PowerShell Cmdlets:

ConvertTo-Json - Convert an object to a JSON-formatted string.

Copyright © 1999-2022
Some rights reserved