gpt4 book ai didi

Powershell 如何将 System.Collections.Generic.Dictionary 转换为 PSCustomObject?

转载 作者:行者123 更新时间:2023-12-03 13:50:00 35 4
gpt4 key购买 nike

我有一个 System.Collections.Generic.Dictionary,我通过运行下面的代码片段获得了它。如何将 $Obj 转换为 PSCustomObject?

[void][System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions")
$jsonserial= New-Object -TypeName System.Web.Script.Serialization.JavaScriptSerializer
$jsonserial.MaxJsonLength = 67108864
$Obj = $jsonserial.DeserializeObject($JsonString)

最佳答案

New-Object应该从 PS 2.0 开始工作:

$custom = new-object PSCustomObject -Property $obj

关于Powershell 如何将 System.Collections.Generic.Dictionary 转换为 PSCustomObject?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27338009/

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