Link to home
Start Free TrialLog in
Avatar of Jeffrey George
Jeffrey GeorgeFlag for Malaysia

asked on

Deserialize Json result

Hi

I am working on an application to access data via API using VB.NET.

I have so far managed to request for and retrieve a security token in the format as shown below:

{"success":true,"token":"eyJhbGciOiJIUzI1NiIsImNhbGciOiJERUYifQ.eNqqVkpOyc9NzMxTslLKTcxJrCzOTDRU0lFKrShQsjI0tTACYjNT01oAAAAA__8.ElaYAGRsAV43lh2OyQ4eR1wF4UIKl7tpHS7YFamVGD8"}

I need to retrieve the "token" value and use that to access the server and request specific information.

I have created a class


Public Class SecurityToken

    <JsonProperty("success")>
    Public Property Success As String

    <JsonProperty("token")>
    Public Property Token As String()

End Class

And in my code, I successfully get to this point where I get the result as shown above


Dim dataStream As Stream = response.GetResponseStream()
Dim reader As StreamReader = New StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()

I am stuck at this point in trying to split the result and retrieve just the token to use in further processing.

Any help would be appreciate.

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jeffrey George

ASKER

Hi Ryan

Pleasure to meet you, and thank you very much, your solution worked.

Have a good day!

Regards

Jeffrey
Coool, glad that it worked.