I am trying to convert some parameters that I receive in a json in whole, but for some strange reason I do not get it, can anyone know that I am failing ???
switch (response.StatusCod) {
case (System.Net.HttpStatusCode.OK):
res_Label_api.Text = "good";
var responseString = await response.Content.ReadAsStringAsync();
// var xjson = JsonConvert.DeserializeObject(responseString);
var xjson = JsonConvert.DeserializeObject < DatosEnvio > (responseString); // hasta aquí que recibe todos los datos del json
var xjson_id = xjson.IdUsuario; // pero una vez aquí me dice que le paso un parametro null D:
int xid = Convert.ToInt32(xjson_id);
}
//modelo
public class DatosEnvio
{
public string Usuario { get; set; }
public string IdUsuario { get; set; }
public string Nombre { get; set; }
}
public class RootObject
{
public DatosEnvio DatosEnvio { get; set; }
public object DatosEnvioJson { get; set; }
public object DatosEnvioJsonDatos { get; set; }
public object DatosEnvioJsonTitulos { get; set; }
public object tabla { get; set; }
public object tablas { get; set; }
public string bandera { get; set; }
public string mensaje { get; set; }
}
//json
{
"DatosEnvio": {
"Usuario": "prueba",
"IdUsuario": "1",
"Nombre": "Desarrollo Aige"
},
"DatosEnvioJson": null,
"DatosEnvioJsonDatos": null,
"DatosEnvioJsonTitulos": null,
"tabla": null,
"tablas": null,
"bandera": "0",
"mensaje": "Acceso exitoso"
}