Skip to content

Instantly share code, notes, and snippets.

@shvydky
Last active December 7, 2016 06:38
Show Gist options
  • Save shvydky/5317207 to your computer and use it in GitHub Desktop.
Save shvydky/5317207 to your computer and use it in GitHub Desktop.
Read Large JSON
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Diagnostics;
using System.IO;
namespace ParseJSON {
class Program {
static void Main(string[] args) {
using (var reader = new JsonTextReader(new StreamReader(@"D:\large.json"))) {
var result = reader.Read();
if (reader.TokenType != JsonToken.StartArray)
throw new ApplicationException("Incorrect file format");
else
result = reader.Read();
while (result && reader.TokenType == JsonToken.StartObject) {
JToken obj = JObject.ReadFrom(reader);
result = reader.Read();
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment