【发布时间】:2012-09-05 15:32:46
【问题描述】:
我正在尝试让RestSharp 使用我拥有的宁静服务。一切似乎都运行良好,除非我通过POST 传递的对象包含一个列表(在这种特殊情况下是string 的列表)。
我的对象:
public class TestObj
{
public string Name{get;set;}
public List<string> Children{get;set;}
}
当它被发送到服务器时,Children 属性将作为带有内容System.Collections.Generic.List`1[System.String] 的字符串发送。
这就是我发送对象的方式:
var client = new RestClient();
var request = new RestRequest("http://localhost", Method.PUT);
var test = new TestObj {Name = "Fred", Children = new List<string> {"Arthur", "Betty"}};
request.AddObject(test);
client.Execute<TestObj>(request);
是我做错了什么,还是 RestSharp 中的错误? (如果有区别,我使用的是 JSON,而不是 XML。)
【问题讨论】:
标签: json serialization restsharp