0
0
PowerShellscripting~5 mins

JSON operations (ConvertFrom-Json, ConvertTo-Json) in PowerShell - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the PowerShell cmdlet <code>ConvertFrom-Json</code> do?
It takes a JSON string and turns it into PowerShell objects you can work with easily.
Click to reveal answer
beginner
What is the purpose of ConvertTo-Json in PowerShell?
It converts PowerShell objects into a JSON string format, which can be saved or sent to other programs.
Click to reveal answer
beginner
How would you convert a JSON string stored in a variable $jsonString to a PowerShell object?
Use $obj = $jsonString | ConvertFrom-Json to get a PowerShell object from the JSON string.
Click to reveal answer
beginner
How can you convert a PowerShell object $obj back to a JSON string?
Use $jsonString = $obj | ConvertTo-Json to get a JSON string from the object.
Click to reveal answer
beginner
Why is JSON useful in scripting and automation?
JSON is a simple text format to share data between programs and scripts, making automation easier and more flexible.
Click to reveal answer
Which cmdlet converts a JSON string into a PowerShell object?
AConvertTo-Json
BConvertFrom-Xml
CConvertTo-Xml
DConvertFrom-Json
What does ConvertTo-Json output?
AJSON string
BXML string
CPowerShell objects
DCSV string
If you want to send data from PowerShell to a web API, which cmdlet helps prepare the data?
AConvertFrom-Json
BConvertTo-Json
CInvoke-WebRequest
DGet-Content
What type of data does ConvertFrom-Json produce?
APlain text
BHTML code
CPowerShell objects
DBinary data
Which of these is a correct way to convert JSON text stored in $json to an object?
A$json | ConvertFrom-Json
B$json | ConvertTo-Json
CConvertTo-Json $json
DConvertFrom-Json -InputObject $json
Explain how you would convert a JSON string to a PowerShell object and then back to JSON.
Think about the flow: JSON string → object → JSON string
You got /3 concepts.
    Why is JSON a popular format for scripting and automation tasks?
    Consider why scripts often use JSON to talk to other programs or APIs
    You got /4 concepts.