JSonDotnetEncoder.cs 538 B

1234567891011121314151617181920212223
  1. #if !BESTHTTP_DISABLE_SIGNALR && BESTHTTP_SIGNALR_WITH_JSONDOTNET
  2. using System.Collections.Generic;
  3. using Newtonsoft.Json;
  4. namespace BestHTTP.SignalR.JsonEncoders
  5. {
  6. public sealed class JSonDotnetEncoder : IJsonEncoder
  7. {
  8. public string Encode(object obj)
  9. {
  10. return JsonConvert.SerializeObject(obj);
  11. }
  12. public IDictionary<string, object> DecodeMessage(string json)
  13. {
  14. return JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
  15. }
  16. }
  17. }
  18. #endif