I'm trying to get a range of json values into a C# DataTable. I'm at the point where Visual Studio recognises the json objects, but I'm getting this error:
Newtonsoft.Json.JsonSerializationException: 'Additional text found in JSON string after finishing deserializing object.'
Here is an example of the json array:
{
"aaData": [
[
1,
"Stop",
"14/03 15:30:03",
"14/03 15:30:58",
0,
"Address",
"Lat, Long",
184,
0,
9,
"False"
],
[
1,
"Stop",
"14/03 15:30:03",
"14/03 15:30:58",
0,
"Address",
"Lat, Long",
184,
0,
9,
"False"
]
]
}
And I'm using this code:
JToken token = JObject.Parse(responsetext);
string apistatus = token.SelectToken("aaData").ToString();
DataSet table = JsonConvert.DeserializeObject<DataSet>(apistatus);
But it is at that last line that the exception is thrown.
If I print the string apistatus to the console I can see it has got the arrays - and even when using the JSON Visualiser in VS the arrays are being recognised - but not sure what is wrong. Here's the string apistatus in the console:
[
[
1,
"Stop",
"14/03 15:30:03",
"14/03 15:30:58",
0,
"Address",
"Lat, Long",
184,
0,
9,
"False"
],
[
1,
"Stop",
"14/03 15:30:03",
"14/03 15:30:58",
0,
"Address",
"Lat, Long",
184,
0,
9,
"False"
]
]
What am I doing wrong? Or is there a much better way to get this particular json array of values into a DataTable?