从Json HTTP响应中获取值

时间:2017-03-15 17:40:20

标签: c# json vb.net linq

导入Newtonsoft.Json.Linq

Public NotInheritable Class MainPage

Inherits Page

Public result As String = ""
Public Sub Btn_Test_Click(sender As Object, e As RoutedEventArgs) Handles Btn_Test.Click
    getRequest("http://192.168.1.242/control?callback=cname&cmd=get_state_sensor&number=1")
    Dim s As String = result

    TBox1.Text = result

End Sub


Public Async Sub getRequest(uri As String)
    Dim httpClient As New System.Net.Http.HttpClient
    Dim response As System.Net.Http.HttpResponseMessage = Await httpClient.GetAsync(uri)
    result = Await response.Content.ReadAsStringAsync()
End Sub

结束班

0 个答案:

没有答案