gpt4 book ai didi

json - 在Powershell 2.0中读取JSON对象

转载 作者:行者123 更新时间:2023-12-03 01:30:06 26 4
gpt4 key购买 nike

我正在使用 Powershell 2.0(目前无法升级到 V3.0),我想从下面读取 JSON 对象:

{"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,因此您可以加载该程序集并使用 JSON parser这是可用的。这是一个快速示例:

[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

关于json - 在Powershell 2.0中读取JSON对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17601528/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com