I have json that is returned similar to:
{
"access_token" : "....",
"token_type" : "....",
"expires_in" : "...."
}
I have a class that I want to deserialize this into, but the fields are:
public string AccessToken { get; set; }
public string TokenType { get; set; }
public int ExpiresIn { get; set; }
I have attempted DataMember(Name="access_token") and the like for the 3 properties, but any time I have attempted to bind to it, it fails (int is 0, strings are null). The only way I've been able to get it to work is a bit... wordy:
var test = JObject.Parse(result);
var test2 = new AuthorizeToken() {
AccessToken = test["access_token"].ToString(),
ExpiresIn = Convert.ToInt32(test["expires_in"]),
TokenType = test["token_type"].ToString()
};
When I do this, test2 is populated appropriately, but I'd prefer do some type of
Deserialize<AuthorizeToken>(result);
with Json.NET