如何在C#中从JSON对象访问值

我收到来自Azure httpsClient Rest API的响应。如何访问此JSON对象中的值。

我需要获取限制,currentValue和name.localizedValue 我的最终目标是将这3列值转储到SQL表中。

httpClient.DefaultRequestHeaders.Remove("Authorization");
httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
HttpResponseMessage response = await httpClient.GetAsync(URI);

var HttpsResponse = await response.Content.ReadAsStringAsync();
var Result =  JsonConvert.DeserializeObject<object>(HttpsResponse);

Console.WriteLine(Result);

输出:

{
  "value": [        
    {
      "limit": 225,
      "unit": "Count",
      "currentValue": 144,
      "name": {
        "value": "cores",
        "localizedValue": "Total Regional vCPUs"
      }
    },
    {
      "limit": 25000,
      "unit": "Count",
      "currentValue": 13,
      "name": {
        "value": "virtualMachines",
        "localizedValue": "Virtual Machines"
      }
    },
    {
      "limit": 2500,
      "unit": "Count",
      "currentValue": 0,
      "name": {
        "value": "virtualMachineScaleSets",
        "localizedValue": "Virtual Machine Scale Sets"
      }
    },
    {
      "limit": 3000,
      "unit": "Count",
      "currentValue": 0,
      "name": {
        "value": "dedicatedVCpus",
        "localizedValue": "Dedicated vCPUs"
      }
    },
    {
      "limit": 100,
      "unit": "Count",
      "currentValue": 0,
      "name": {
        "value": "lowPriorityCores",
        "localizedValue": "Total Regional Low-priority vCPUs"
      }
    },
    {
      "limit": 125,
      "unit": "Count",
      "currentValue": 96,
      "name": {
        "value": "standardDSv2Family",
        "localizedValue": "Standard DSv2 Family vCPUs"
      }
    },
    {
      "limit": 100,
      "unit": "Count",
      "currentValue": 8,
      "name": {
        "value": "standardESv3Family",
        "localizedValue": "Standard ESv3 Family vCPUs"
      }
    },
    {
      "limit": 100,
      "unit": "Count",
      "currentValue": 16,
      "name": {
        "value": "standardDSv2PromoFamily",
        "localizedValue": "Standard DSv2 Promo Family vCPUs"
      }
    }
  ]
}

(抱歉,在奇怪的无意义的文本下方添加了帖子,这是我对我拥有更多代码并要求我提供更多详细信息的补充,因此不允许我提交问题。 ssssssssssssssssssssssssss sssssssssssssssssss

评论