I'm working with REST services from Oracle database, and I'm trying to cast the json response into my class model, but I can't get it, this is the type of the JSON
{
"items": [
{
"id": 2,
"role_id": 1,
"local_id": 1,
"nombre": "test",
"apellido": "test",
"email": "test",
"phone_number": "123123",
"rut": "1",
"password": "1231212",
"token": "C0C7C76D30BD3DCAEFC96F40275BDC0A"
},
{
"id": 1,
"role_id": 6,
"local_id": 1,
"nombre": "Cristobal",
"apellido": "Gonzalez",
"email": "cristobal@test.com",
"phone_number": "22222",
"rut": "2-1",
"password": "actualizada",
"token": "34173CB38F07F89DDBEBC2AC9128303F"
}
],
"hasMore": false,
"limit": 25,
"offset": 0,
"count": 2,
"links": [
{
"rel": "self",
"href": "https://jl0ax7eh9vmstei-portafolio2020.adb.sa-saopaulo-1.oraclecloudapps.com/ords/admin/usuario/user"
},
{
"rel": "describedby",
"href": "https://jl0ax7eh9vmstei-portafolio2020.adb.sa-saopaulo-1.oraclecloudapps.com/ords/admin/metadata-catalog/usuario/item"
},
{
"rel": "first",
"href": "https://jl0ax7eh9vmstei-portafolio2020.adb.sa-saopaulo-1.oraclecloudapps.com/ords/admin/usuario/user"
}
]
}
I just need to work with the items part, and my class is like
public int id_usuario { get; set; }
public int id_rol { get; set; }
public int id_local { get; set; }
public string pnombre { get; set; }
public string papellido { get; set; }
public string correo { get; set; }
public string phone { get; set; }
public string rut { get; set; }
public string pass { get; set; }
public string token { get; set; }
So my trouble is that when I try to Deserialize it, I can't parse into my class, I supposed that is for the "extra stuff" that I don't need... This is my method to convert into my class type
string strresult_test = null;
using (Stream stream = responseObjGet.GetResponseStream())
{
StreamReader sr = new StreamReader(stream);
strresult_test = sr.ReadToEnd();
strresult_test.ToString();
Response.Write(sr);
sr.Close();
}
var serial = new JavaScriptSerializer();
ItemUsuario testv2 = JsonConvert.DeserializeObject<ItemUsuario>(strresult_test);
Response.Write("g");
List<ItemUsuario> salida = serial.Deserialize<List<ItemUsuario>>(strresult_test);
When I get the "testv2" variable, is null... What else can I do?
Thanks for the help!