且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从URL的JSON字符串?

更新时间:2023-01-26 07:51:47

使用 Web客户端 System.Net

var json = new WebClient().DownloadString("url");

请即 Web客户端的IDisposable ,所以你可能会添加使用语句来此生产code。这将是这样的:

Keep in mind that WebClient is IDisposable, so you would probably add a using statement to this in production code. This would look like:

using (WebClient wc = new WebClient())
{
   var json = wc.DownloadString("url");
}