ServiceStack.Text support for NodaTime.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tools
.gitignore
LICENSE
LICENSE_NodaTime
LICENSE_ServiceStack
NodaTimeLogo.png
README.md
build.bat
build.cake
build.ps1
cake.config

README.md

NodaTime.Serialization.ServiceStackText

ServiceStack.Text JSON serialization support for NodaTime v2. This library will work with v5.0 and later versions of ServiceStack.Text and ServiceStack.Text.Core.

Typical Setup

DateTimeZoneProviders.Tzdb
  .CreateDefaultSerializersForNodaTime()
  .ConfigureSerializersForNodaTime();

Optional Setup

There are static extension methods to allow for optional fluent configuration.

Use Iso Interval Serializer

DateTimeZoneProviders.Tzdb.CreateDefaultSerializersForNodaTime()
  .WithIsoIntervalSerializer()
  .ConfigureSerializersForNodaTime();

Use Iso Period Serializer

DateTimeZoneProviders.Tzdb.CreateDefaultSerializersForNodaTime()
  .WithNormalizingIsoPeriodSerializer()
  .ConfigureSerializersForNodaTime();

One-Off Serializer Setup

//You could create you own serializer by implementing IServiceStackSerializer<T>
NodaSerializerDefinitions.LocalTimeSerializer.ConfigureSerializer();

Alternatively, you can create your own implementation of INodaSerializerSettings to suit your specific needs.

Default Serializers

The SerivceStack.Text serializer uses the same default serialization formats as those used in the Json.NET serializers. You can optionally change the Interval serializer to use the ISO 8601 Interval spec.

Notes

  • Serializer setup should only occur once in your application root.
  • Serialization setup should occur before any serialization occurs with ServiceStack.Text or there may be undesirable behavior.
  • If using with ServiceStack, serializer setup should occur before Init of the AppHost.
  • For Value types, this will also setup the nullable serializer for that value type.
  • Since this is a custom serializer for ServiceStack.Text, calls to JsConfig.Reset() will remove the custom serializers.

Using the Code

Continuous Integration

CodeBetter.com CI Build Status: Build Status

Special Thanks to JetBrains and CodeBetter for hosting this project!