【发布时间】:2011-12-12 21:49:19
【问题描述】:
我正在尝试实现一个远程 REST 服务,该服务用于处理我的 MVC3 Web 应用程序的所有逻辑,到目前为止,我能够从 Web 服务中检索序列化对象,但我一直坚持将对象反序列化到我的要传递给 View 的 ViewModel。
这是我的控制器:
[HttpGet]
public ActionResult Index()
{
string versions;
using (var webClient = new WebClient())
{
versions = webClient.DownloadString("http://myservice/GetVersions");
}
// deserialize JSON/XML somehow...
//IEnumerable<VersionViewModel> model = ?
return View(model);
}
我需要做什么才能将我从 web 服务收到的 JSON 转换为 ViewModel 以呈现我的视图?谢谢。
【问题讨论】:
标签: json web-services asp.net-mvc-3 rest