Created
October 3, 2019 19:09
-
-
Save aonurdemir/af4661356bb2bffe187104af0eb00a25 to your computer and use it in GitHub Desktop.
Read json file c#
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
public static void ReplaceJsonValue() | |
{ | |
string filepath = "../../json1.json"; | |
string result = string.Empty; | |
using (StreamReader r = new StreamReader(filepath)) | |
{ | |
var json = r.ReadToEnd(); | |
var jobj = JObject.Parse(json); | |
foreach (var item in jobj.Properties()) { | |
item.Value = item.Value.ToString().Replace("v1", "v2"); | |
} | |
result = jobj.ToString(); | |
Console.WriteLine(result); | |
} | |
File.WriteAllText(filepath, result); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment