I have a problem when I try to parse a large json file, which has around 200mb.
I’m doing it with Newtonsoft.Json. It gives OutOfMemory exception.
This is my code:
using (StreamReader sr=File.OpenText("path"))
{
JObject file= (JObject)JToken.ReadFrom(new JsonTextReader(sr));
}
How can I do this ? ( preferable using JObject )
You can use
JsonTextReaderto read text in aDataReaderfashion as stated in this question:Incremental JSON Parsing in C#
You will have to code your own logic to process JSON data, but it will for sure solve your memory issues:
You would actually build a recursive JSON parser.