Wondering how to deserialize the following string in c#:
"[{\"access_token\":\"thisistheaccesstoken\"}]"
I know how to do it if the json was:
"{array=[{\"access_token\":\"thisistheaccesstoken\"}]}"
I'd do it like this:
public class AccessToken
{
public string access_token {get;set;}
public DateTime expires { get; set; }
}
public class TokenReturn
{
public List<AccessToken> tokens { get; set; }
}
JavaScriptSerializer ser = new JavaScriptSerializer();
TokenReturn result = ser.Deserialize<TokenReturn>(responseFromServer);
But without that array name, I'm not sure. Any suggestions?
Thanks!
Never mind, Just did it with:
JavaScriptSerializer ser = new JavaScriptSerializer();
List<AccessToken> result = ser.Deserialize<List<AccessToken>>(jsonString);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With