-
Notifications
You must be signed in to change notification settings - Fork 445
Support specifying custom JSON.NET options for JsonHubProtocol #261
Comments
No, customizing serialization is not possible at the moment. This case is quite interesting however - you want to modify the payload on the server to get camelCased property names because you are using only a javascript client. If you used heterogeneous clients (e.g. javascript and C#) then modifying the payload on the server side wouldn't work since the clients use different conventions. |
@davidfowl do you have a design in mind? |
This should be in preview. We need a way to configure these options and have them flow to the |
We could try resolving JsonSerializerSettings from DI in the JSonHubProtocol ctor. Note that if we decide to support this we will need two JSonSerializers - one for the hub protocol itself that is not configurable and one for serializing custom types. |
another option (if registering in DI feels to general) is to have it in HubOptions where it could possibly be specified per HubProtocol implementation. |
That actually feels like the best option to me. Have a way to specify Hub Protocol options (of various kinds, including which protocols to allow) |
Hi, maybe what I'm about to propose is the same as you (because I didn't really understood it :-$) but why can't you just do something like:
And this would only applied to what's send in the "arguments" property of the response? This way, the user would be able to choose if he wants to keep the default behaviour (for C# client for example) or switch to Camel case (for JavaScript client). |
@ssougnez Yep, that's basically exactly what we're talking about. It'll likely be a |
This is now in via #743 |
I would like to add a contract resolver to signalR requests in order to camel case my return types. I tried used the pattern described here but the contract resolver seems to be ignored. Has this been implemented? Here's a repository with my attempt. I would expect the returned value from GetMessage to be
{ message: 'a message' }
but I get{ Message: 'a message' }
.The text was updated successfully, but these errors were encountered: