I am doing a little exercise in xamarin forms to get a request from an api, and the api return me this
{
"valido": true,
"nombre": "Anderson",
"apellido": "Laverde Gracia",
"email": "[email protected]",
"periodo": "0985",
"emplid": "8923082",
"x-t6519fdd1s5q": "eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE1NTk3MTQ1MTUsInN1YiI6ImFuZGVyc29ubGF2ZXJkZTE2In0.T8his-2cpGgFwkxmDGOeZ2rAGKIrSyrgPvfUs2xZUkiD6Z4hi7Dhg-p28y8dKBr3TW_97kqnSEY1Pg-k5AYuAA",
"token_expire_in": 1559714515418,
"roles": [
"3"
]
}
But When I create a class in xamarin with this parameters all works
public class MyUser
{
public bool valido { get; set; }
public string nombre { get; set; }
public string apellido { get; set; }
public string email { get; set; }
public string periodo { get; set; }
public string emplid { get; set; }
public string x-t6519fdd1s5q { get; set; }
public List<string> roles { get; set; }
}
}
except this
public string x-t6519fdd1s5q { get; set; }
The error says that x-t6519fdd1s5q isnt recognized as string, and i need this value. how can i access to it ?
Help me please..
use the JsonProperty
attribute to map that value to a valid C# name
[JsonProperty("x-t6519fdd1s5q")]
public string x_t6519fdd1s5q { get; set; }