Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

JSON serilizer and date format

$
0
0

Hi

I've got a StartDate propetry in my ServiceItem defined like this:

        [DataType(DataType.Date)]
        [Required]
        public DateTime? StartDate { get; set; }

Then when I try to serialize SubscriptionServiceItem into Json using:

return Json(Mapper.Map<SubscriptionServiceItemDto>((await _context.ServiceItems.OfType<SubscriptionServiceItem>().Where(g => g.Id == id && g.IsArchived == false).ToListAsync()).First()));

I get the following response

"startDate": "2013-05-11T00:00:00",

Is it possiblie in ASP.NET Core to format the JSON result for that particular property like this:

"startDate": "2013-05-11",

Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>