Web API–How to change Default Serializer settings

Out of box, Web API provides a way to serialize using JSON and XML.
In this blog post, I will describe how you can control JSON settings for the default serializer.

JSON Settings.

e.g Say you want your date to be formatted as per Microsoft format as opposed to ISO standard (for whatever reason).
All you do is get hold of the jsonFormatter and then use SerializerSettings to set DateFormatHandling.

JsonDateFormatCode

ISO Date Format for JSON

isoFormat

Microsoft Date Format for JSON.

microsoftdateFormat

By default, Json.NET will use ISO format for your date time format serialization

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s