{
"success": 1,
"items": [
{
"ItemID": "13",
"ItemName": "Diamond (50 Kg PP)",
"ItemDesc": "",
"MRP": "0",
"Rate": "0",
"Unit": "",
"Weight": "50",
"ItemGroup": ""
},
{
"ItemID": "8",
"ItemName": "Extra Milk (59 Kg Jute)",
"ItemDesc": "",
"MRP": "0",
"Rate": "0",
"Unit": "",
"Weight": "59",
"ItemGroup": ""
},
{
"ItemID": "19",
"ItemName": "Extra Milk (59 Kg PP)",
"ItemDesc": "",
"MRP": "0",
"Rate": "0",
"Unit": "",
"Weight": "59",
"ItemGroup": ""
},
{
"ItemID": "23",
"ItemName": "Test222",
"ItemDesc": "",
"MRP": "0",
"Rate": "0",
"Unit": "",
"Weight": "50",
"ItemGroup": ""
}
]
}
my code
public async void myweb()
{
string vJ = "";
string url = "https://crmscf.vidyasystems.com/api/gen/items.php";
var client = new RestClient(url);
var request = new RestRequest();
var responce = client.Get(request);
// Console.WriteLine(responce.Content.ToString());
// txtJson.Text = responce.Content.ToString();
vJ = responce.Content.ToString();
DataTable dataTable = (DataTable)JsonConvert.DeserializeObject(@vJ, (typeof(DataTable)));
dgvXml.DataSource = dataTable;
}
I am getting error :
Newtonsoft.Json.JsonSerializationException: 'Unexpected JSON token when reading DataTable. Expected StartArray, got StartObject. Path '', line 1, position 1.'
The following uses a different method to read json. The models and helper class belong in their own files.