Skip to content

Commit

Permalink
Use JsonSerializer that has been configured for parameter deserializa…
Browse files Browse the repository at this point in the history
…tion

- The parameter deserialization in SignalR used a hard-coded JsonSerializer which meant it could not be overridden
  • Loading branch information
Andrew Butler committed Jul 21, 2016
1 parent 353a4e7 commit b8eeb92
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Microsoft.AspNet.SignalR.Core/Hubs/HubRequestParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public HubRequest Parse(string data, JsonSerializer serializer)
request.Method = deserializedData.Method;
request.Id = deserializedData.Id;
request.State = GetState(deserializedData);
request.ParameterValues = (deserializedData.Args != null) ? deserializedData.Args.Select(value => new JRawValue(value)).ToArray() : _emptyArgs;
request.ParameterValues = (deserializedData.Args != null) ? deserializedData.Args.Select(value => new JRawValue(value, serializer)).ToArray() : _emptyArgs;

return request;
}
Expand Down
7 changes: 4 additions & 3 deletions src/Microsoft.AspNet.SignalR.Core/Json/JRawValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@ namespace Microsoft.AspNet.SignalR.Json
internal class JRawValue : IJsonValue
{
private readonly string _value;
private readonly JsonSerializer _serializer;

public JRawValue(JRaw value)
public JRawValue(JRaw value, JsonSerializer serializer)
{
_value = value.ToString();
_serializer = serializer;
}

public object ConvertTo(Type type)
{
// A non generic implementation of ToObject<T> on JToken
using (var jsonReader = new StringReader(_value))
{
var serializer = JsonUtility.CreateDefaultSerializer();
return serializer.Deserialize(jsonReader, type);
return _serializer.Deserialize(jsonReader, type);
}
}

Expand Down

0 comments on commit b8eeb92

Please sign in to comment.