Skip to content

Instantly share code, notes, and snippets.

@lfgrando
Last active July 20, 2018 18:16
Show Gist options
  • Save lfgrando/4c9a6bf770770f3c25928b2210f905e7 to your computer and use it in GitHub Desktop.
Save lfgrando/4c9a6bf770770f3c25928b2210f905e7 to your computer and use it in GitHub Desktop.
Rename JObject Token
private void RenameToken(JToken token, string newName)
{
var parent = token.Parent;
if (parent == null)
throw new InvalidOperationException("The parent is missing.");
var newToken = new JProperty(newName, token);
parent.Replace(newToken);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment