Created
March 28, 2017 18:21
-
-
Save bleroy/7879720551d779c20cdd4dbb36e78836 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
JArray largeJson; | |
// read asynchronously from a file | |
using (FileStream asyncFileStream = new FileStream(@"large.json", FileMode.Open, FileAccess.Read, FileShare.Read, 4096, true)) | |
{ | |
largeJson = await JArray.LoadAsync(new JsonTextReader(new StreamReader(asyncFileStream))); | |
} | |
JToken user = largeJson.SelectToken("$[?(@.name == 'Woodard Caldwell')]"); | |
user["isActive"] = false; | |
// write asynchronously to a file | |
using (FileStream asyncFileStream = new FileStream(@"large.json", FileMode.Open, FileAccess.Write, FileShare.Write, 4096, true)) | |
{ | |
await largeJson.WriteToAsync(new JsonTextWriter(new StreamWriter(asyncFileStream))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment