IConvertible support for JValue

Feb 14, 2012 at 4:50 PM

Hi,

Is there a way to add IConvertible support to JValue?

Here is a sample:

JObject tmp = JObject.Parse(responseJson);
AuthenticationTokenInfo res = new AuthenticationTokenInfo() {               
    Token = (String)tmp["access_token"],                                            // ok
    RefreshToken = tmp["refresh_token"].ToObject<String>(),              // ok
    OrganizerKey = Convert.ToString(tmp["organizer_key"]),                // failed
};

Actual error: "Unable to cast object of type 'Newtonsoft.Json.Linq.JValue' to type 'System.IConvertible'"

Would be nice to support this interface as we can cast/convert to simple types anyway.