How to replace the ServiceStack.Text JSON Serializer/Deserializer globally

Is it possible to replace the global ServiceStack.Text JSON serializer/deserializer with a 3dparty serializer/deserializer e.g. with Jil ?

The ContentTypes API controls which formats ServiceStack is configured with.

So you can swap out the JSON Serializer used by overriding it with:

ContentTypes.Register(MimeTypes.Json, 
    (IRequest req, object dto, Stream s) => ..., // serialize to stream
    (Type type, Stream fromStream) => obj);      // deserialize from stream into object

Keep in mind there are a number of JSON features that uses features in ServiceStack.Text serializer also you need to be careful if your Service needs to support C# or other Service Clients as they send JSON using ServiceStack.Text (or the format it expects) where you can face interoperability issues if JIL/alt-serializer doesn’t support the default format sent in which case you may need to configure ServiceStack.Text to change the default serialization, configure your serializer to support format ServiceStack.Text sends or use string properties to force a specific format for primitive data types like DateTime, TimeSpan if the formats between different serializers are incompatible.

Note: As there will likely be interoperability issues from using a different impl, this is not a supported configuration.

Thanks… I’ll try it out pretty soon