Add DeepClone method to JToken

Nov 30, 2010 at 5:41 PM

A DeepClone method on JToken would be nice. It looks like there is already an internal CloneToken method, so presumably it could just call that.

Here is my workaround, but it probably isn't as efficient as calling CloneToken.

public static class JTokenUtility
{
    public static JToken DeepClone(this JToken token)
    {
        return JToken.ReadFrom(token.CreateReader());
    }
}

Coordinator
Dec 27, 2010 at 8:26 PM

Done. JToken now also implements ICloneable.