Custom ServiceClient deserialization

I am receiving a response from a ServiceStack service that is a Dictionary<Dto1, Dto2> sent from the server. where Dto1 is not a string, and a complex object.

The JsonServiceClient is unable to deserilize this into the type: Dictionary<Dto1, Dto2> on the client, and instead returns a null.

Presumably, the response is not recognized as a dictionary, hence the null. Which is probably fair enough.

Is it possible to define my own deserialization handler for the JsonServiceClient, and if so, how?

JSON requires a string key so it can only be a string or a scalar value, i.e. it can’t be a complex type.

The way to create a custom serializer is to register a custom JsConfig<T> serializer, but the complex type key needs to be serialized as a string.