简体   繁体   English

Winform DataGridView-绑定/使用JSON Web服务吗?

[英]Winform DataGridView - Bind/Consume JSON Webservice?

I have a winform application that contains a datagridview that I would like to populate using a JSON webservice. 我有一个winform应用程序,其中包含一个我想使用JSON Web服务填充的datagridview。 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. Web服务可以输出XML或JSON,而XML没问题,但我认为JSON将提供更快的响应。

You can create a class to mimic the json structure and then use the javascript serializer to convert json response to a bindable list 您可以创建一个类来模仿json结构,然后使用javascript序列化程序将json响应转换为可绑定列表

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 这个 Google搜索为您提供了一些有关如何使用JavaScriptSerializer类反序列化json对象的完整示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM