Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 循环字典对象和显示数据_C#_Asp.net_C# 4.0_Shopify_Asp.net Webpages - Fatal编程技术网

C# 循环字典对象和显示数据

C# 循环字典对象和显示数据,c#,asp.net,c#-4.0,shopify,asp.net-webpages,C#,Asp.net,C# 4.0,Shopify,Asp.net Webpages,我使用GET请求来shopify,shopify返回一个json 我正在将json反序列化到下面的对象(字典) 如何循环通过下面的对象并仅访问 “title”键值对 <code> @using System.Web.Script; @using System.Web.Script.Serialization; @{ var url = string.Format("https://{0}.myshopify.com/admin/orders.jso

我使用GET请求来shopify,shopify返回一个json

我正在将json反序列化到下面的对象(字典)

如何循环通过下面的对象并仅访问 “title”键值对

<code>
    @using System.Web.Script;
    @using System.Web.Script.Serialization;
    @{
      var url = string.Format("https://{0}.myshopify.com/admin/orders.json?
      fields=billing_address", AppState["ShopName"]);
      var request = (HttpWebRequest)WebRequest.Create(url);
      request.Method = "GET";
      request.ContentType = "application/json";
      request.Credentials=new 
      NetworkCredential((string)AppState["PrivateAppKey"], 
      (string)AppState["PrivateAppSecret"]);
      request.PreAuthenticate = true;

      WebResponse response = request.GetResponse();

      StreamReader reader = new StreamReader(response.GetResponseStream());
      string urlText = reader.ReadToEnd(); // response from your url.

      var jsonSerializer = new JavaScriptSerializer();
      dynamic brokenJson = jsonSerializer.Deserialize<dynamic>(urlText);

    }
</code>

@使用System.Web.Script;
@使用System.Web.Script.Serialization;
@{
var url=string.Format(“https://{0}.myshopify.com/admin/orders.json?
字段=账单地址”,AppState[“ShopName”];
var request=(HttpWebRequest)WebRequest.Create(url);
request.Method=“GET”;
request.ContentType=“application/json”;
request.Credentials=new
NetworkCredential((字符串)AppState[“PrivateAppKey”],
(字符串)AppState[“PrivateAppSecret”];
request.PreAuthenticate=true;
WebResponse=request.GetResponse();
StreamReader=新的StreamReader(response.GetResponseStream());
字符串urlText=reader.ReadToEnd();//来自url的响应。
var jsonSerializer=新的JavaScriptSerializer();
dynamic brokenJson=jsonSerializer.Deserialize(urlText);
}
字典 字符串“blogs”=对象[] [0]=字典 字符串“id”=int 94686854 字符串“句柄”=字符串“3d打印” 字符串“title”=字符串“3D打印” 字符串“更新时间”=字符串“2017-04-04T23:56:33+05:30” 字符串“可注释”=字符串“中等” 字符串“feedburner”=字符串“” 字符串“feedburner_位置”=字符串“” 字符串“创建时间”=字符串“2017-04-04T23:56:33+05:30” 字符串“模板后缀”=(空) 字符串“标记”=字符串“” [1] =字典 字符串“id”=int 47272710 字符串“句柄”=字符串“新闻” 字符串“title”=字符串“关于ATRANGI的新闻” 字符串“更新时间”=字符串“2017-04-07T13:20:45+05:30” 字符串“可注释”=字符串“是” 字符串“feedburner”=字符串“Atrangi LatestNews” 字符串“feedburner_位置”=字符串http://feeds.feedburner.com/" 字符串“创建时间”=字符串“2016-01-06T20:56:04+05:30” 字符串“模板后缀”=(空) 字符串“标记”=字符串“”
您的回答不够,但可能需要这样做:

foreach(var blog in yourObject["blogs"])
{
   var title = blog["title"];
}

请显示json和反序列化。我投票决定结束这个问题,因为它不清楚。@Gautam Sharma,你解决你的问题了吗?@giladgreen下面是请求api的代码
foreach(var blog in yourObject["blogs"])
{
   var title = blog["title"];
}