ConvertFrom-Json max length

前端 未结 4 577
情话喂你
情话喂你 2020-12-01 21:12

I have a problem using PowerShell v3 when converting JSON strings over 2MB in size. The default limit in JSON serializer used by PowerShell is set to 2MB which explains the

4条回答
  •  爱一瞬间的悲伤
    2020-12-01 21:23

    I had the same problem and was able to solve it like this:

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

    You can use $jsonserial.MaxJsonLength to manipulate the MaxJsonLength property

    source: https://social.technet.microsoft.com/Forums/windowsserver/en-US/833c99c1-d8eb-400d-bf58-38f7265b4b0e/error-when-converting-from-json?forum=winserverpowershell&prof=required

提交回复
热议问题