首页 > 解决方案 > 从 C# 中的 URL 获取 Json 数据

问题描述

我是 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 数据

标签: jsonc#-4.0

解决方案


这是您正在寻找的其余端点:

http://hololens5.northeurope.cloudapp.azure.com/INTERSHOP/rest/WFS/inSPIRED-
inTRONICS_Business-Site/-;loc=en_US;cur=USD/products/1599925

有关其他休息端点的文档:https: //support.intershop.com/kb/index.php/Display/T27711


推荐阅读