Created
April 2, 2014 05:00
-
-
Save lamw/9928202 to your computer and use it in GitHub Desktop.
Parsing JSON in PowerShell using ConvertFrom-Json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$json = @" | |
{"A": {"property1": "value1", "property2": "value2"}, "B": {"property1": "value3", "property2": "value4"}} | |
"@ | |
$parsed = $json | ConvertFrom-Json | |
foreach ($line in $parsed | Get-Member) { | |
echo $parsed.$($line.Name).property1 | |
echo $parsed.$($line.Name).property2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello!
I don't know JSON so I did this:
This produces:
Seems like an odd object model - this might be the basis behind the difficulty working with the data, rather than PowerShell. Did you mean something like this?
Which produces this:
Cheers!