0
我已经定义在C#类型称为Signalr发送嵌套键/值字典
using Message = System.Collections.Generic.Dictionary<string, object>;
我有从C#服务器发送此到C#客户端没有问题。
但现在他们想要的值对一个是消息的阵列,如下图所示(该跟踪虚拟值变量):
Message msg = new Message();
msg.Add("timestamp", Tools.ToMS(seconds, microseconds));
msg.Add("DateTime", Tools.ToISO(this.seconds, this.microseconds));
msg.Add("guid", Guid.NewGuid().ToString());
msg.Add("heading", this.heading);
msg.Add("correction", this.correction);
msg.Add("valid", this.valid);
msg.Add("lat", lat);
msg.Add("lon", lon);
msg.Add("altitude", altitude);
msg.Add("Channel", "Oxford.GPS");
Message[] tracked = new Message[2];
tracked[0] = new Message();
tracked[1] = new Message();
tracked[0].Add("first", 1);
tracked[1].Add("second", 2);
msg.Add("tracked", tracked);
return msg;
好的,我得到在发送没有错误,但在接收侧嵌入的字典不转换为字典,代替我正在Newtonsoft.Json.Linq.JArray
Type: Object
HasValues: 1
First: [1x1 Newtonsoft.Json.Linq.JProperty]
Last: [1x1 Newtonsoft.Json.Linq.JProperty]
Count: 1
Parent: [1x1 Newtonsoft.Json.Linq.JArray]
Root: [1x1 Newtonsoft.Json.Linq.JArray]
Next: [1x1 Newtonsoft.Json.Linq.JObject]
Previous: []
Path: [1x1 System.String]
这里的阵列是什么详细跟踪被示出在客户机到达的,这厕所KS好我的外行人看来:
{"C":"d-4A172629-B,5549|C,0|D,1","M":[{"H":"GatewayHub","M":"post","A":[{"timestamp":1450469910308,"DateTime":"2015-12-18T20:18:30.3090000Z","guid":"60ef4307-1225-40f9-b0e0-f2f1d87e760d","heading":210.340958,"correction":3,"valid":true,"lat":42.299856271140619,"lon":-83.698864895162188,"altitude":269.147216796875,"Channel":"Oxford.GPS","tracked":[{"first":1},{"second":2}]}]}]})
是的,不管你信不信,我然后通过一个事件,MATLAB,这也适用发送这一点,但不是为嵌套值。
你可以试试这个:https://stackoverflow.com/questions/32314638/signalr-typenamehandling – dbc