While attempting to extract data from JSON using JavaScriptSerializer, particular difficulties are encountered while looking through the data of object type.
Based on the below sample data, the following code has been written:
var serializer = new JavaScriptSerializer();
dynamic outp = serializer.DeserializeObject(out3);
var a = outp["Number"]; // is OK, returns "1"
var b = outp["Description"]; // stuck in looking through "Description" to access "address", then extract the value of "street_2", as an illustration.
Feedback (not involving ideally the definition of a class with related properties) would highly be appreciated. Thanks.
{
"Number": 1,
"Description": [
{
"id": "PO1234",
"country": "TE",
"No": "4050",
"safeNo": "LU37",
"name": "stuck",
"address": {
"street_1": "adhoc, 0098, country",
"street_2": "94 street",
"city": "stackoverflow",
"zip": "stack"
},
"is_EU": "Y",
"conti": "E",
"date": "2019-08-14T21:43:02.000Z"
}
]
}