Reputation: 13856
I have bunch of TimeSpan properties in response from Web API. By default JSON serializer includes decimal values of seconds as well in response. E.G. 08:30:00.000909
These micro-seconds values are not needed in response.
Is it possible to override JSON serializer so that it could skip out milli/micro-second components in the serialized JSON response?
Upvotes: 1
Views: 863
Reputation: 23042
You may want to use custom serializer for your Web API http://tinymission.com/post/custom-serialization-for-json-properties-in-web-api
Or before you convert your DTO to Model, you can use Custom Date and Time Format Strings.
https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx
Upvotes: 3