Michał Gajek - 259 - Jun 9, 2014

Is that possible to provide custom DateTime deserialization format for just one specific field in one specific DTO? The client I’m integrating is inconsistent when it comes to dates, and one of the DTOs provide very strange format of date. I wonder if there’s any attribute / configuration dictionary that would make it possible with ServiceStack, or do I have to fall back to “string” property & manual processing.

Yeah, there different date format are listed in:
https://github.com/ServiceStack/ServiceStack.Text/blob/master/src/ServiceStack.Text/JsConfig.cs#L848 e.g:

JsConfig.DateHandler = DateHandler.ISO8601;

Michał Gajek:

+Demis Bellot  I believe this sets the “global” handler. I need to specify the handler for a specific field in a specific DTO. I need all my dates to be ISO8601 except one very specific field which has completely custom  date format …

You can scope configuration inside using(JsConfig.With(...)) { ... } but if that’s not suitable either than yeah you’d probably need serialize a string into your desired format.

Michał Gajek:

Ok, thanks! I’ll go with string field and a request filter or sth.