我刚接触 JSON,想要从链接中获取 JSON 数据。在网上搜索后,我写了以下代码:
private void button1_Click(object sender, EventArgs e)
{
string url = @"http://hololens5.northeurope.cloudapp.azure.com/INTERSHOP/web/WFS/inSPIRED-inTRONICS_Business-Site/en_US/-/USD/ViewProduct-Start?SKU=1599925&CategoryName=151&CatalogID=Computers";
using (WebClient wc=new WebClient())
{
json = wc.DownloadString(url);
}
string path = @"ouptputfileJSON.json";
if (!File.Exists(path))
{
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine(json);
}
}
}
当我执行此代码时,输出在HTML页面中。如何在提供的链接中获取所选产品的JSON数据?