Last active
December 7, 2016 06:38
-
-
Save shvydky/5317207 to your computer and use it in GitHub Desktop.
Read Large JSON
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
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