I am new to c# How do I deserialize the json below to .Net object
Response (JSON):
Success Response :
{
"code": "0001",
"status": "success",
"message": " data retrieved",
"data": {
"balance": {
"Date": "2 JAnuary 1920",
"accountNo": "123456",
"accountName": "My account name",
"balance": "400.0",
" transactions ": [
{
"transactionDate": [1920, 1, 23],
"amount": 0.000000,
"createdDate": [1920, 1, 23],
"amountIndicator": 2,
"narration": "cash withdrawal",
"uniqueIdentifier": "00023",
"details": "cash withdrawal"
}
]
}
}
}
string Url = "http://postalpincode.in/api/pincode/";
HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(Url);
webrequest.Method = "GET";
webrequest.ContentType = "application/json";
HttpWebResponse webresponse = (HttpWebResponse)webrequest.GetResponse();
StreamReader reader = new StreamReader(webresponse.GetResponseStream(), System.Text.Encoding.GetEncoding("utf-8"));
string readToEnd = reader.ReadToEnd();
Please how do I do it am getting error:
Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[MyT]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly. To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.