code
public string getallcustomer()
{
DataTable dt = new DataTable();
CustomerService _customerService = new CustomerService();
dt = _customerService.Getallcustomer();
List<Dictionary<string, object>> lstPersons = _customerService.GetTableRows(dt);
// var json = JsonSerializer.Serialize(lstPersons);
//return Json(lstPersons, JsonRequestBehavior.AllowGet);
string json = JsonConvert.SerializeObject(lstPersons);
return json;
}
output:
"[{\"FirstName\":\"gateway\",\"PhoneNumber\":\"\",\"Balance\":-10.0000,\"CompanyName\":\"gateway\",\"Email\":\"1gateway@Sipkernel.com\",\"CustomerID\":1},{\"FirstName\":\"a-Office\",\"PhoneNumber\":null,\"Balance\":20.0000,\"CompanyName\":\"a-Office\",\"Email\":\"office@a.com\",\"CustomerID\":2}]"