Using ServiceStack.Text as JSON Serializer for SignalR -
to have consistent serialization across application layers, want use same serialization library (servicestack.text) signalr use everywhere else.
while following signalr's wiki entry replacing used json serializer, created basic handler:
public class signalrservicestackjsonserializer : ijsonserializer { public void serialize(object value, textwriter writer) { var selfserializer = value ijsonwritable; if (selfserializer != null) selfserializer.writejson(writer); else jsonserializer.serializetowriter(value, writer); } public object parse(textreader reader, type targettype) { return jsonserializer.deserializefromreader(reader, targettype); } }
integration:
var serializer = new signalrservicestackjsonserializer(); globalhost.dependencyresolver.register(typeof(ijsonserializer), () => serializer);
unfortunately, after integrating it, signalr js client different packages default serializer. looks like, default serializer generates (at least non-user messages) json properties capped 1 character, not occur after replacing servicestack.text. thus, signalr tries access 'i' received 'id'. unable find respective parts of signalr server-side sourcecode.
did wrong or have create more complex wrapper use servicestack.text json serializer?
i wouldn't bother trying. have deep dependency on json.net , we've removed extensibility in next release. sorry.