I wrote some code and it works, but I double-convert json twice, and it's a little embarrassing.
I get data that is wrapped in a "d" object, how can I get its contents right away
Here's the Json that I get:
{
"d": [
{
"__type": "MdoCommonWs.WsStructures.WsWmsLookupResult",
"CallResult": {
"Id": 0,
"Data": null,
"ErrorId": 0,
"ErrorDescription": null
},
"Article": {
"Id": "001",
"Description": "ANKER M12 MECHANISCH",
"Unit": "pieces",
"UnitPrice": 7,
"MinStock": 0,
"MaxStock": 0,
"Info": "ANKER MECHANISCH M12",
"Photo": [],
"PhotoUrl": "",
"WeightUnit": "kg",
"Weight": 0.05,
"CountStock": 0
},
"Locations": [
{
"LocationId": "00.00.AA.01.01.01.02",
"Type": 0,
"IsBlocked": false,
"ArticleId": "001",
"Stock": 2,
"TotalStock": 2,
"LastActionDate": "/Date(1480334382093)/",
"LastInventoryDate": "/Date(1480334319527)/"
}
],
}],
}
Here is my code to convert:
var rootJObject = JObject.Parse(stringSerialized);
var serialize = rootJObject["d"].ToString();
return JsonConvert.DeserializeObject<TResult>(serialize);
How can I do this more efficiently?
JObject@PalleDue, I'm guessing OP wants it strongly typedTResultd?