How to capture/ get value of Output StreamReader

Frangky Bunga 41 Reputation points
2023-10-12T07:45:18.69+00:00

Dear All,

I use source code like this image. If the program is run, it will produce output like this:User's image

what I want to ask. How to get the value from "Status"?User's image

Developer technologies | VB
{count} votes

3 answers

Sort by: Most helpful
  1. Viorel 125.7K Reputation points
    2023-10-12T08:10:13.9033333+00:00

    Try a possibility:

    'Dim text = ret.ReadToEnd()
    Dim text = "{""status"":""valid"", ""chatId"":""******@c.us""}"
    
    Dim d As New With {.status = ""}
    
    d = System.Text.Json.JsonSerializer.Deserialize(text, d.GetType)
    
    Dim status As String = d.status
    
    MsgBox(status)
    

  2. Frangky Bunga 41 Reputation points
    2023-10-12T09:02:45.69+00:00
    Dim ret As New System.IO.StreamReader(WebRequest.GetResponse().GetResponseStream())
    
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
            Dim parsejson As JObject = JObject.Parse(ret.ReadToEnd)
            Dim theStatus = parsejson.SelectToken("status").ToString()
            MsgBox("Status is : " + theStatus)
    
    0 comments No comments

  3. Frangky Bunga 41 Reputation points
    2023-10-12T09:03:09.2+00:00
    Dim ret As New System.IO.StreamReader(WebRequest.GetResponse().GetResponseStream())
    
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
            Dim parsejson As JObject = JObject.Parse(ret.ReadToEnd)
            Dim theStatus = parsejson.SelectToken("status").ToString()
            MsgBox("Status is : " + theStatus)
    
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.