1
我使用c#在asp.net mvc项目中使用域名的promo pricing api。我想获得像'dotgold'这样的特定产品密钥的代理商价格。在这个Api对象名称是59,58等动态的。我怎样才能做到这一点。下面是该API的JSON对象...当对象名称为动态时,如何获取json对象的值?
{
"59": {
"customerprice": "528.00",
"timestamp": "2017-02-10 13:59:16.711147+00",
"actiontype": "addnewdomain",
"resellerpricecurrencysymbol": "INR",
"resellerpricetwo": "748.00",
"isactive": "true",
"starttime": "1486393372",
"productkey": "dotjetzt",
"creationdt": "1486735157",
"promoid": "13333",
"serviceprovidersellingcurrency": "INR",
"istrickleallow": "true",
"resellerpriceone": "489.50",
"resellerid": "683272",
"barrierprice": "680.0",
"period": "1",
"endtime": "1491004799",
"resellerprice": "445.0"
},
"58": {
"customerprice": "302.50",
"timestamp": "2017-02-10 13:59:16.711147+00",
"actiontype": "addnewdomain",
"resellerpricecurrencysymbol": "INR",
"resellerpricetwo": "451.00",
"isactive": "true",
"starttime": "1486393234",
"productkey": "dotgold",
"creationdt": "1486735157",
"promoid": "13332",
"serviceprovidersellingcurrency": "INR",
"istrickleallow": "true",
"resellerpriceone": "264.00",
"resellerid": "683272",
"barrierprice": "410.0",
"period": "1",
"endtime": "1491004799",
"resellerprice": "240.0"
}
}
下面是desrialize的JSON对象
string redirect = @"https://test.httpapi.com/api/resellers/promo-details.json?auth-userid=xxxx&api-key=xxxxxxxxxxxx";
string html;
var headers = new System.Net.WebHeaderCollection();
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(redirect);
request.AutomaticDecompression = DecompressionMethods.GZip;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream stream = response.GetResponseStream();
using (StreamReader reader = new StreamReader(stream))
{
html = reader.ReadToEnd();
}
var stuff = JObject.Parse(html2);
这真的很难帮你不知道你是如何在一般反序列化JSON或什么JSON的样子。请提供[mcve] - 并注意这不是ASP.NET特定的,因此控制台应用程序将使演示更加容易。 –
我已经提供了json对象 –
但是,您至今没有提供任何代码,您提供的JSON远非最小 - 我们不需要为每个值查看18个属性,只需足够做出具有代表性的样本。 –