我如何在C#中的Web服务中接收和显示JSON数据? [英] How I can receive and display JSON data in my web service in C # ?

查看:434
本文介绍了我如何在C#中的Web服务中接收和显示JSON数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在C#中的Web服务中接收和显示JSON数据?



我在网页服务(page.asmx)中,我想要编写一个接收并显示JSON数据的函数。



数据:



[{id:1,name:公务员 诉讼: 是的, 公司: 是},{ ID: 2, 名: 刑法, 诉讼: 是的, 公司:是} ...

how I can receive and display JSON data in my web service in C # ?

I am in the web page service (page.asmx) and I want write a function that receives and displays the JSON data.

The data:

[{"id":"1","name":"Civil","litigation":"yes","corporate":"yes"},{"id":"2","name":"Criminal","litigation":"yes","corporate":"yes"}...

推荐答案

如果我说得对,你不需要任何中间网络服务。

你可以使用 WebClient [ ^ ]类直接从给定的URL下载JSON ...

使用WebClient.DownloadData(),而不是将生成的字节数组转换为字符串并使用它!
If I got you right you need no any intermediate web service.
You can use WebClient[^] class to download the JSON directly from the given URL...
Use WebClient.DownloadData(), than convert the resulting byte array to string and use it!


这篇关于我如何在C#中的Web服务中接收和显示JSON数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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