Метод:
[Route("api/vms/getpowerstatus/{vmsid}")]
[HttpGet]
public string getpowerstatus(string vmsid)
{
Result rs = new Result();
try
{
DataSet ds = new DataSet();
String timeStamp = GetTimestamp();
string q = "select vmsid, vmspowerstatus ,vmspowerdatetime from public.vmssnapshot ";
ds = vm.GetVMS(q);
rs.vmsid = vmsid;
rs.status = "success";
string json = JsonConvert.SerializeObject( ds.Tables[0] , Formatting.None);
return json;
}
catch (Exception ex)
{
}
}
Ответ:
"[{\"vmsid\":\"512\",\"vmspowerstatus\":null,\"vmspowerdatetime\":null},{\"vmsid\":\"VMSBhandup98\",\"vmspowerstatus\":null,\"vmspowerdatetime\":null},{\"vmsid\":\"tquwuer\",\"vmspowerstatus\":null,\"vmspowerdatetime\":null},{\"vmsid\":\"VMSBlock\",\"vmspowerstatus\":\"1\",\"vmspowerdatetime\":1539022768},{\"vmsid\":\"uu4443\",\"vmspowerstatus\":\"1\",\"vmspowerdatetime\":1534917021},{\"vmsid\":\"cms_bhandup\",\"vmspowerstatus\":\"1\",\"vmspowerdatetime\":1539022544},{\"vmsid\":\"vmsBolakk\",\"vmspowerstatus\":\"1\",\"vmspowerdatetime\":1539631400}]"
Желаемый ответ:
[{vmsid:'512',vmspowerstatus:'test'.....}]