I want to parse JSON in PowerShell but I can't use the new v3 functions that are available in PowerShell. My first thought was to load the JSON.Net assembly and use that to parse the JSON string but it doesn't work as I expect it to.
I have this JSON:
$json = "{""Name"": ""Apple"",
""Price"": 3.99,
""Sizes"": [
""Small"",
""Medium"",
""Large""]}"
I load the JSON.NET assembly with this code:
[Reflection.Assembly]::LoadFile("$currentPath\Newtonsoft.Json.dll”)
And tries to parse it with
$result = [Newtonsoft.Json.JsonConvert]::DeserializeObject($json)
Now I expect that $result["Name"] is Apple but I get nothing there. Any ideas?
The code ´$result.ContainsKey("Name")returnsTruebut$result.GetValue("Name")returnsnull`.