- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我以 JSON 格式启动此 RestSharp 查询:
var response = restClient.Execute<Report>(request);
我得到的响应包含这些数据
[
{
"Columns":
[
{"Name":"CameraGuid","Type":"Guid"},
{"Name":"ArchiveSourceGuid","Type":"Guid"},
{"Name":"StartTime","Type":"DateTime"},
{"Name":"EndTime","Type":"DateTime"},
{"Name":"TimeZone","Type":"String"},
{"Name":"Capabilities","Type":"UInt32"}
],
"Rows":
[
[
"00000001-0000-babe-0000-00408c71be50",
"3782fe37-6748-4d36-b258-49ed6a79cd6d",
"2013-11-27T17:52:00Z",
"2013-11-27T18:20:55.063Z",
"Eastern Standard Time",
2147483647
]
]
}
]
我正在尝试将其反序列化为这组类:
public class Report
{
public List<ReportResult> Results { get; set; }
}
public class ReportResult
{
public List<ColumnField> Columns { get; set; }
public List<RowResult> Rows { get; set; }
}
public class ColumnField
{
public string Name { get; set; }
public string Type { get; set; }
}
public class RowResult
{
public List<string> Elements { get; set; }
}
不幸的是,结果数据为空,我得到了这个异常:
Unable to cast object of type 'RestSharp.JsonArray' to type 'System.Collections.Generic.IDictionary`2[System.String,System.Object]'.
我不知道这里出了什么问题。我将不胜感激。
最佳答案
试试这个:
var response = restClient.Execute<List<ReportResult>>(request);
编辑
您还应该将 ReportResult
更改为:
public class ReportResult
{
public List<ColumnField> Columns { get; set; }
public List<List<string>> Rows { get; set; }
}
您可以去掉 Report
和 RowResult
。
关于c# - RestSharp JSON 数组反序列化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20251020/
我正在使用 RestSharp 访问 RubyOnRails API。您可能知道,RoR 喜欢参数名称采用 model_name[property] 形式。另一方面,RestSharp 不喜欢它。 F
我刚刚下载了 DropNet 来尝试使用它。我在尝试执行 new DropNetClient 时遇到异常: Method not found: System.String RestSharp.Rest
当我尝试使用 nuget 将 RestSharp 添加到可移植类库项目时,我得到以下信息: Could not install package 'RestSharp 104.1'. You are t
我有以下代码片段,它一直在我身上失败: ServicePointManager.ServerCertificateValidationCallback += (o, c, ch, er) => tru
当我像这样在 RestSharp 中发出请求时: var response = client.Execute(request); 我收到以下错误: "Unable to cast object of
有什么方法可以从 RestSharp RestRequest 中删除 header 吗? 我在项目页面中偶然发现了这个问题,但看不到它曾经被应用过: https://github.com/restsh
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
我正在使用 RestSharp 将信息发送到 API。我想记录发送到此 API 的 XML,以便稍后进行调试。 我想做这样的事情: var request = new RestRequest(reso
下面是使用标准 HttpWebRequest 和 HttpWebResponse 完成的 POST 请求。基本上它发布带有一些参数的二进制文件。 我怎样才能用 RestSharp 做同样的事情? 来源
目前无法解决问题:无法将类型为“RestSharp.JsonArray”的对象转换为类型为“System.Collections.Generic.IDictionary”2[System.String
我使用了在 ASP.NET Framework version 4.5.1 上运行的 MVC Web 应用程序. 我做了 nopcommercePlugin .我正在将版本 3.4 升级到 3.5 更
我用过restsharp对于我的一些 .net 项目。我发现它对于从网络服务获取 Json 数据并将它们转换为 .net 对象非常有用。我需要一个类似的java框架。我想用它来为我的 android
最近我在用 RestSharp消耗我的 Restful 资源。并期望在服务器和客户端之间与 JSon 交换数据。下面是我的 C# 代码。 var client = new RestSharp.Rest
我的应用程序要求是使用签名程序集。我使用 Visual Studio 2012 命令工具签署了 RestSharp 程序集。应用程序构建成功,但运行时出现以下错误: Could not load fi
在特定情况下,我需要能够在请求/响应中禁用压缩。 使用 Firefox RestClient 我能够将一些 xml 发布到 Web 服务并使用单个 header 参数“Accept-Encoding”
我正在尝试使用 RestSharp(我的第一次)。我正在使用他们的示例: var client = new RestClient( "http://example.com" ); var reques
我查看了有关此问题的其他问题,但似乎没有任何内容可以回答我的问题。希望因为我的问题/问题似乎是一个简单的解决方案。 我使用 nuget 安装了 RestSharp。 using RestSharp;
我正在尝试使用 RestSharp 编码示例来连接到 MailGun。在下面的代码中,请参阅: client.Authenticator = new HttpBasicAuthenticator("X
我正在使用 RestSharp。我使用 XML 作为我的数据的传输编码,但后来我 had problems有了这个,所以我转而使用 JSON。现在我也遇到了问题! 在我尝试传递一个包含字节数组 (*)
我刚刚更新了在 ASP.NET Framework 4.5.2 版上运行的 MVC Web 应用程序。我正在使用 Twilio 发送 SMS 消息: var twilio = new TwilioRe
我是一名优秀的程序员,十分优秀!