在Powershell 2.0中阅读Json对象 [英] Read Json Object in Powershell 2.0
本文介绍了在Powershell 2.0中阅读Json对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Powershell 2.0(到目前为止无法升级到V3.0)&我想阅读下面的Json对象.
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\"}]}"
能帮我吗?
谢谢.
推荐答案
您可能已经可以使用System.Web.Extensions,因此可以加载该程序集并使用
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)
参考: http://msdn.microsoft.com/en -us/library/system.web.script.serialization.javascriptserializer.aspx
这篇关于在Powershell 2.0中阅读Json对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文