I am using Powershell 2.0 (cannot make an upgarde to V3.0 as of now) & I want to read the below Json object.
"{\"DevResults\":[{\"TechnologyName\":\"AD\",\"RuleName\":\"SOA account (user logon/display name)\",\"OutputValue\":\"SOADevClientCenter\"},
{\"TechnologyName\":\"AD\",\"RuleName\":\"SOA account (pre-Windows 2000)\",\"OutputValue\":\"SOADevCliCen\"},
\"ProdResults\":[{\"TechnologyName\":\"AD\",\"RuleName\":\"SOA account (user logon/display name)\",\"OutputValue\":\"SOAClientCenter\"},
{\"TechnologyName\":\"AD\",\"RuleName\":\"BPM Service Account (pre-Windows 2000)\",\"OutputValue\":\"BPM_CliCen_05\"}]}"
Can you please help me with the same.
Thanks.
You probably have the System.Web.Extensions available, and as such you can load that assembly and use the JSON parser that is available. Here is a quick sample:
[System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions")
$json = "{a:1,b:2,c:{nested:true}}"
$ser = New-Object System.Web.Script.Serialization.JavaScriptSerializer
$obj = $ser.DeserializeObject($json)
Reference: http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx
来源:https://stackoverflow.com/questions/17601528/read-json-object-in-powershell-2-0