从网络服务获取 属性

getting property from webservice

我正在尝试使用 get 方法从 WS 的信息中获取一些信息。

我确实设法从一个 WS 中获得了所需的信息,但不是从第二个 WS 中获得的。

   string url = "";
       
        url = "http://...";

        List<Client> listOfClient = null;
        string host = url;
       
        WebRequest req = WebRequest.Create(@host);
       
       try
        {
            HttpWebResponse resp = req.GetResponse() as HttpWebResponse;
            
            if (resp.StatusCode == HttpStatusCode.OK)
            {
                
                using (var reader = new StreamReader(resp.GetResponseStream()))
                {
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    var objText = reader.ReadToEnd();
                   

                    listOfClient = (List<Client>)js.Deserialize(objText, typeof(List<Client>));

                  
                }
            }
 name = listOfClient.FirstOrDefault().name;

                return name;

        }
        catch (Exception)
        {
            throw;
        }

这是 Json :

[
  {
    
    "city": NY,
    "age": 30,
    "Name": "Robert",
  }
]

我需要使用相同的逻辑阅读属性要约

{
  "contract": "480788888",
  "numbers": [
    {
      "type": "IDEI",
      "value": "5987699118"
    }
  ],
  
  "status": "Valid",
  "offer": "PNE",
}

使用Newtonsoft.Json.Linq

dynamic obj= JObject.Parse("{ 'contract': '480788888', 'numbers': [ { 'type': 
'IDEI', 'value': '5987699118' } ],'status': 'Valid', 'offer': 'PNE', }");

string offer = obj.offer;