Complete the code to convert a JSON string to a PowerShell object.
$jsonString = '{"name":"Alice","age":30}' $obj = $jsonString | [1]
The ConvertFrom-Json cmdlet converts a JSON string into a PowerShell object.
Complete the code to convert a PowerShell object to a JSON string.
$obj = @{name='Bob'; age=25}
$jsonString = $obj | [1]The ConvertTo-Json cmdlet converts a PowerShell object into a JSON string.
Fix the error in the code to correctly convert JSON string to object.
$jsonString = '{"city":"Paris","population":2140000}' $obj = [1] $jsonString
To convert JSON text to an object, use ConvertFrom-Json. Using ConvertTo-Json here is wrong.
Fill both blanks to create a JSON string from an object and then convert it back to an object.
$obj = @{fruit='Apple'; color='Red'}
$json = $obj | [1]
$newObj = $json | [2]First, convert the object to JSON with ConvertTo-Json. Then convert JSON back to object with ConvertFrom-Json.
Fill all three blanks to convert a JSON string to object, modify it, and convert back to JSON.
$jsonString = '{"animal":"Dog","age":5}' $obj = $jsonString | [1] $obj.age = $obj.age + 1 $newJson = $obj | [2] Write-Output [3]
Convert JSON string to object with ConvertFrom-Json, then back to JSON with ConvertTo-Json. Finally, output the new JSON string.