reading HttpwebResponse json response, C#

后端 未结 3 779
伪装坚强ぢ
伪装坚强ぢ 2020-12-25 10:55

In one of my apps, I am getting the response from a webrequest. The service is Restful service and will return a result similar to the JSON format below:

{
          


        
3条回答
  •  孤城傲影
    2020-12-25 11:55

    If you're getting source in Content Use the following method

    try
    {
        var response = restClient.Execute>(restRequest);
    
        var jsonContent = response.Content;
    
        var data = JsonConvert.DeserializeObject>(jsonContent);
    
        foreach (EmpModel item in data)
        {
            listPassingData?.Add(item);
        }
    }
    catch (Exception ex)
    {
        Console.WriteLine($"Data get mathod problem {ex} ");
    }
    

提交回复
热议问题