Answers for "find and replace json data in c#"

C#
0

c# update value in a json file

string json = File.ReadAllText("settings.json");
dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(json);
jsonObj["Bots"][0]["Password"] = "new password";
string output = Newtonsoft.Json.JsonConvert.SerializeObject(jsonObj, Newtonsoft.Json.Formatting.Indented);
File.WriteAllText("settings.json", output);
Posted by: Guest on December-06-2021
0

json.net jobject replace value

JObject json= JObject.Parse(jsonString);
JArray entityTypeDtos= (JArray)json["EntityTypeDto"];
foreach(var e in entityTypeDtos)
{
  if(e["Language"] != null)
     e["Language"]="EN";
}
Posted by: Guest on October-25-2021

C# Answers by Framework

Browse Popular Code Answers by Language