Cannot deserialize the current JSON array (e.g. [1,2,3])

前端 未结 6 1833
遥遥无期
遥遥无期 2020-12-01 12:47

I am trying to read my JSON result.

Here is my RootObject

public class RootObject
{
public int id { get; set; }
public bool is_defau         


        
6条回答
  •  情深已故
    2020-12-01 13:45

    You can use this to solve your problem:

    private async void btn_Go_Click(object sender, RoutedEventArgs e)
    {
        HttpClient webClient = new HttpClient();
        Uri uri = new Uri("http://www.school-link.net/webservice/get_student/?id=" + txtVCode.Text);
        HttpResponseMessage response = await webClient.GetAsync(uri);
        var jsonString = await response.Content.ReadAsStringAsync();
        var _Data = JsonConvert.DeserializeObject >(jsonString);
        foreach (Student Student in _Data)
        {
            tb1.Text = Student.student_name;
        }
    }
    

提交回复
热议问题