Please have a look at
Deserialize a DataSet[
^]
As OriginaGriff already suggested you have to embed the raw data into square brackets.
You could achieve this by using the following method:
private static string AddSquareBrackets(string json)
{
return $"[{json}]";
}
var json = @"
{
'access_token': 'b9fbb7994e50899e2d5eaf012eee9fb0.d3e8a8d4ba960e9aca4cc156',
'api_domain': 'http://www.codeproject.com',
'token_type': 'Bearer',
'expires_in': 12312
}";
json = AddSquareBrackets(json);
var dt = ConvertJsonToDataTable(json);
private static DataTable ConvertJsonToDataTable(string jsonData)
{
try
{
return JsonConvert.DeserializeObject<DataTable>(jsonData);
}
catch
{
return null;
}
}
The handling ot the exception message here is left out for brevity.
In case of a failure you can return null.
You have to check then if the result is not null.