using Newtonsoft.Json.Linq;
public static void Main()
""Login"": ""someLogin"",
""Street"": ""someStreet"",
JObject jo = JObject.Parse(json);
jo.Property("bad").Rename("good");
Console.WriteLine(jo.ToString());
jo["good"].Rename("better");
Console.WriteLine(jo.ToString());
public static class NewtonsoftExtensions
public static void Rename(this JToken token, string newName)
throw new ArgumentNullException("token", "Cannot rename a null token");
if (token.Type == JTokenType.Property)
if (token.Parent == null)
throw new InvalidOperationException("Cannot rename a property with no parent");
property = (JProperty)token;
if (token.Parent == null || token.Parent.Type != JTokenType.Property)
throw new InvalidOperationException("This token's parent is not a JProperty; cannot rename");
property = (JProperty)token.Parent;
var existingValue = property.Value;
var newProperty = new JProperty(newName, existingValue);
property.Replace(newProperty);