C# 将值转换为列表时出错<;字符串>;从动态数据
我尝试转换具有结构的动态数据时出错 “[“myvalue1”、“myvalue2”]” 列出 向服务发送请求的我的函数C# 将值转换为列表时出错<;字符串>;从动态数据,c#,json,dynamic,C#,Json,Dynamic,我尝试转换具有结构的动态数据时出错 “[“myvalue1”、“myvalue2”]” 列出 向服务发送请求的我的函数 List<string> SFRecipients = new List<string>(); SFRecipients.Add("myvalue1"); SFRecipients.Add("myvalue2"); var jsonSerialiser = new JavaScriptS
List<string> SFRecipients = new List<string>();
SFRecipients.Add("myvalue1");
SFRecipients.Add("myvalue2");
var jsonSerialiser = new JavaScriptSerializer();
string jSFRecipients = jsonSerialiser.Serialize(SFRecipients);
uri = "http://testservices.com/Send";
client = new RestClient(uri);
request = new RestRequest(Method.POST);
request.AddParameter("SFRecipients", jSFRecipients);
response = client.Execute(request);
List SFRecipients=new List();
添加(“myvalue1”);
添加(“myvalue2”);
var jsonSerialiser=新的JavaScriptSerializer();
字符串jSFRecipients=jsonSerialiser.Serialize(SFRecipients);
uri=”http://testservices.com/Send";
client=新的RestClient(uri);
请求=新的重新请求(方法POST);
AddParameter(“SFRecipients”,jSFRecipients);
响应=客户端。执行(请求);
服务功能
public void Send(JObject data)
{
dynamic Mydata= data;
//Mydata.SFRecipients is = ["myvalue1","myvalue2"]
// i have debuged
List<string> Recipients = Mydata.SFRecipients.ToObject<List<string>>();
public void发送(作业对象数据)
{
动态Mydata=数据;
//Mydata.SFRecipients为=[“myvalue1”、“myvalue2”]
//我已经调试过了
List Recipients=Mydata.SFRecipients.ToObject();
然后我得到一个错误
将值“[“myvalue1”、“myvalue2”]”转换为类型“System.Collections.Generic.List`1[System.String]”路径“”时出错。
这里我遗漏了什么?是否存在任何内部异常?此外,请检查字符串中是否确实没有这些尾随双引号。JSON数组不能从
“
开始。是否存在任何内部异常?此外,请检查字符串中是否确实没有这些尾随双引号。JSON数组不能从开始。”
。