Winform DataGridView - 绑定/使用JSON Webservice? [英] Winform DataGridView - Bind/Consume JSON Webservice?

查看:687
本文介绍了Winform DataGridView - 绑定/使用JSON Webservice?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个winform应用程序,其中包含一个datagridview,我想使用JSON webservice填充。我没有太多运气在网络上找到任何例子,这是可能的吗?



webservice可以输出xml或json,而xml没有问题,但我觉得json会提供更快的回复。



非常感谢任何帮助!

解决方案

您可以创建一个类来模拟json结构,然后使用javascript序列化程序将json响应转换为可绑定列表

  var myList = new JavaScriptSerializer()。反序列化< IList< MyClass>>(json); 

谷歌搜索给你一些关于如何使用反序列化json对象的完整示例JavaScriptSerializer


I have a winform application that contains a datagridview that I would like to populate using a JSON webservice. I am not having much luck finding any examples on the web, is this possible?

The webservice can output xml or json and the xml is no problem but I feel that the json would provide a quicker response.

Any help is greatly appreciated!

解决方案

You can create a class to mimic the json structure and then use the javascript serializer to convert json response to a bindable list

var myList = new JavaScriptSerializer().Deserialize<IList<MyClass>>(json);

This google search gives you some complete examples about how to deserialize a json object using the JavaScriptSerializer class

这篇关于Winform DataGridView - 绑定/使用JSON Webservice?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆