Ashok

Ashok

  • NA
  • 507
  • 76.4k

How to convert Decimal to integer

Jan 6 2021 12:27 PM
Hi All,
 
As I am converting the below JSON from dataset, in the backend oracle it is number datatype.
 
so due this in the json I am getting like decimal value. How to avoid this
 
that not to get like decimal value.
 
{
"max_no": 899.0,
"total": 10200.0,
"no": 123456789.0
}
 
Class file
  1. public class root  
  2. {  
  3.     public decimal max_no { getset; }  
  4.     public double total { getset; }  
  5.     public decimal no { getset; }  
  6. }  
C# code
  1. var JsonList = ds.Tables[0].AsEnumerable().Select(dataRow => new root()  
  2. {  
  3. max_no =dataRow.Field<decimal>("max_no"),  
  4. total = dataRow.Field<double>("total"),  
  5. no = dataRow.Field<decimal>("no")  
  6. }).ToList();  
  7. return Request.CreateResponse(HttpStatusCode.OK, JsonList); 
how to get the JSON as below
 
{
"max_no": 899,
"total": 10200,
"no": 123456789
}

Answers (2)