Skip to content

Instantly share code, notes, and snippets.

@aonurdemir
Created October 3, 2019 19:09
Show Gist options
  • Save aonurdemir/af4661356bb2bffe187104af0eb00a25 to your computer and use it in GitHub Desktop.
Save aonurdemir/af4661356bb2bffe187104af0eb00a25 to your computer and use it in GitHub Desktop.
Read json file c#
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