I am trying to deserialize a JSON result towards dataset
. When trying to do it I throw the following error:
Additional text found in JSON string after finishing deserializing object. Path
'[0].studentID'
, line 1,
I do not see what additional text I may be getting from the JSON
These are the JSON data
[
{
"studentID": "[email protected]",
"facultyID": "[email protected]",
}
]
This is the class created
[Serializable]
class Parameters
{
public string studentID { get; set; }
public string facultyID { get; set; }
}
This is part of my code
IList<Parameters> searchResultsFromJason = new List<Parameters>();
string resultJSonRequest = "";
using (HttpWebResponse resp = req.GetResponse() as HttpWebResponse)
using (var reader = new StreamReader(resp.GetResponseStream()))
{
var result = reader.ReadToEnd();
string resultWebService = Convert.ToString(result);
var JasonResultList = Newtonsoft.Json.JsonConvert.DeserializeObject<JToken>(resultWebService.ToString());
resultJSonRequest = resultWebService;
IList<JToken> results = JasonResultList.ToList();
IList<Parameters> searchResults = new List<Parameters>();
searchResultsFromJason = searchResults;
foreach (JToken resultJAson in results)
{
Parameters searchResult = resultJAson.ToObject<Parameters>();
searchResults.Add(searchResult);
}
}
This is where the code falls and the error 'Additional text found in JSON string after finishing deserializing object. Path '[0].studentID', line 1,'
DataSet dataSet = JsonConvert.DeserializeObject<DataSet>(resultJSonRequest);