0

我在http://respro2013webapi.uhurucloud.com/api/values上托管了一个简单的 webapi ,它返回一个字符串数组

<ArrayOfstring xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<string>value1</string>
<string>value2</string>
</ArrayOfstring>

我在我的 Windows 手机应用程序中使用这个 webapi,当我使用时

var books = JsonConvert.DeserializeObject<Details[]>(e.Result);

它给出了将值“value1”转换为类型的异常错误

如何在 win 手机应用程序的列表中显示结果

4

1 回答 1

1

您的服务器似乎正在返回 XML,并且您正在尝试使用 JSON 解析器来解析 XML,但这是行不通的。既然您说您在服务器上使用 Web API,我认为您需要做的就是告诉服务器您想要返回 JSON,而不是 XML。(Web API 可以输出任何一种格式。)在您的客户端代码中,只需Accept向您的请求添加一个标头,其值为application/json.

于 2013-11-29T18:41:29.173 回答