Here's my code. I'm getting an out of memory exception trying to deserialize. I've tried following other answers and can't get it to work. Any recommendations? The file is 121 MB.
using (StreamReader reader = new StreamReader(filePath))
{
using (JsonReader jr = new JsonTextReader(reader))
{
JsonSerializer serializer = new JsonSerializer();
data = serializer.Deserialize<MyObject>(jr);
}
}
I've also tried this
using (StreamReader reader = new StreamReader(filePath))
{
using (JsonReader jr = new JsonTextReader(reader))
{
while (jr.Read())
{
if (jr.TokenType == JsonToken.StartObject)
{
data = serializer.Deserialize<MyObject>(jr);
}
}
}
}
MyObject
is a List<SubObject>
. SubObject
contains four properties, one being Data
. Data
is a large string and where the majority of this large data is stored and likely where it's failing. There are only two or three SubObjects
in the list