ASP.NET Web API : return decimal with leading zeros

Viewed 49

This is an action method in my controller:

public IActionResult GetProgres()
{
    var exampleProgress = new Progress()
    {
        Total = 100,
        Completed = 5
        Progress = 5m
    };

    return Ok(exampleProgress);
}

which returns a Progress object:

public class Progress
{
    public int Total { get; set; }
    public int Completed { get; set; }
    public decimal Progress { get; set; }
}

I am getting this json output:

{
    "total": 0,
    "sent": 0,
    "progress": 5
}

How can I force "progress": 5 to be a decimal with two decimal places: "progress": 5.00?

0 Answers
Related