Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to parse json array in vb.net?

I am learning about JSON and I want to parse json array and get only one value using VB.Net. I found this QUESTION with answers but I didn't seem to get what I was looking for. According the the questioner, he has this

"links":[
  {
    "rel":"next",
    "href":"www.google.com"
  }
]

and we can use this to parse json array

   links(1).Item("rel")

or this

links(1)("rel")

What if I only have this?

[{
    "rel":"next",
    "href":"www.google.com"
}]

How should I code it without the word links? I understand that links is the table name, isn't it? I tried so many possibilities which give me more errors. I'd appreciate much if anyone can help me out.

P.S. This not a duplicate to this because I am not going to add the information to a DataGridView. What I want here is to parse a field. Get only one result and not the entire list.

like image 240
MAC Avatar asked May 19 '26 11:05

MAC


1 Answers

You need to do use :

Imports Newtonsoft.Json
JsonConvert.DeserializeObject(Of <Your Class object>)(<JSON String>)

go through with this link Deserialize Json

like image 124
Jameel Grand Avatar answered May 21 '26 04:05

Jameel Grand