Using the MVC model, I would like to write a JsonResult that will pass the Json string to the client, and not convert all the data to a Json string right away, and then pass it back to the client. I have actions that require sending very large (over 300,000 entries) as Json transfers, and I think the main implementation of JsonResult is not scalable.
I am using Json.net, I am wondering if there is a way to pass pieces of a Json string when it is being converted.
//Current implementation: response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(Data, formatting)); response.End(); //I know I can use the JsonSerializer instead Newtonsoft.Json.JsonSerializer serializer = new Newtonsoft.Json.JsonSerializer(); serializer.Serialize(textWriter, Data);
However, I'm not sure how I can get the pieces written in textWriter and write back and answer the call to .Flush () until all 300,000 entries are converted to Json.
Is this even possible?
source share