Last active
December 12, 2023 22:45
-
-
Save smarkwell/60159fb1f56498f9a53d to your computer and use it in GitHub Desktop.
Loading large JSON data files into Powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Work around on | |
# ConvertFrom-Json : Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. | |
$json = New-Object -TypeName System.Web.Script.Serialization.JavaScriptSerializer | |
$json.MaxJsonLength = 104857600 #100mb as bytes, default is 2mb | |
$filedata = [System.IO.File]::ReadAllText($JSONDataFile) #Using default encoding | |
$data = $json.DeserializeObject($filedata, [System.Object]) | |
$filedata = $null | |
$json = $null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated the Gist based on this. I haven't tested this. I assume this comes back to Powershell/.NET version at the time I originally wrote the script.
Not sure if my original issues was loading data out of a file or off a web request, thanks for the additional note.