【发布时间】:2016-02-10 16:50:27
【问题描述】:
我正在努力解决这个问题,
我想使用 ArraySegment 传输 Json 对象
我的 JSON 数据是 这种格式
{"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]}
我已经使用this 工具创建了指定的类,比如
public class Employee
{
public string firstName { get; set; }
public string lastName { get; set; }
}
public class RootObject
{
public List<Employee> employees { get; set; }
}
现在我将数据插入到这样的对象中
var objectToSerialize = new RootObject();
objectToSerialize.items = new List<Employee>
{
new Item { firstName="abc", lastName="xyz"},
new Item { firstName="pqr", lastName="stu"}
};
但现在我遇到了问题,我不知道如何使用 网络套接字
通过这个
ArraySegment<byte> max = new ArraySegment<byte>(, , );
await webSocket.SendAsync(max, WebSocketMessageType.Text, true, CancellationToken.None);
【问题讨论】:
标签: c# arrays json c#-4.0 json.net