Is there some way to take only the data from the dataset and ignore the start array 'result' ?
{
"result": [
"",
{
"dataset": [
{
"idSottogruppo": "7",
"Sottogruppo": "Distribuzione Ausiliaria"
}, {
"idSottogruppo": "6",
"Sottogruppo": "Distribuzione Motore"
}, {
"idSottogruppo": "8",
"Sottogruppo": "Filtri"
}, {
"idSottogruppo": "39",
"Sottogruppo": "Motore"
}
]
}
]
}
That's how I did it and it works, I just want to do less code if it's possible as all API methods have the same JSON format.
My Code:
public class OE_GetActiveSubGroupsResultDTO
{
public List<OE_GetSubActiveGroupsListDTO> Result { get; set; }
}
public class OE_GetActiveSubGroupsListDTO
{
public List<OE_GetActiveSubGroupsDTO> Dataset { get; set; }
}
public class OE_GetActiveSubGroupsDTO
{
public string idSottogruppo { get; set; }
public string Sottogruppo { get; set; }
}
public ActionResult ProcessSpareParts(CarViewModel vm)
{
OE_GetActiveItemsResultDTO activeItemsResultDeserialize = JsonConvert.DeserializeObject<OE_GetActiveItemsResultDTO>(GetActiveSubGroups);
foreach(var activeItemsResult in activeItemsResultDeserialize.Result[1].Dataset)
{
OE_GetActiveItemsDTO activeItems = new JavaScriptSerializer().Deserialize<OE_GetActiveItemsDTO>(activeItemsResult .ToString());
...
}
}

Here is the one line code