I have just started the parse the Json structure in my program. My ServerResponse is look like as follows.
I dont know how to paste the json structure here. Therefore i just copy and paste the structure here.
{
"pot_searches": [
{
"id": 24,
"links": {
"results": [
{
"type": "pot_search_results",
"id": 191
},
{
"type": "pot_search_results",
"id": 192
},
{
"type": "pot_search_results",
"id": 193
},
{
"type": "pot_search_results",
"id": 194
},
{
"type": "pot_search_results",
"id": 195
},
{
"type": "pot_search_results",
"id": 196
},
{
"type": "pot_search_results",
"id": 197
},
{
"type": "pot_search_results",
"id": 198
},
{
"type": "pot_search_results",
"id": 199
},
{
"type": "pot_search_results",
"id": 200
}
],
"query_tree": null
},
"description": "hello example",
"query_text": "Heat",
"limit": 10,
"error": null,
"created_by": null,
"href": "http://blabla/bla/bla/pot/searches/24"
},
{
"id": 25,
"links": {
"results": [
{
"type": "pot_search_results",
"id": 201
},
{
"type": "pot_search_results",
"id": 202
},
{
"type": "pot_search_results",
"id": 203
},
{
"type": "pot_search_results",
"id": 204
},
{
"type": "pot_search_results",
"id": 205
},
{
"type": "pot_search_results",
"id": 206
},
{
"type": "pot_search_results",
"id": 207
},
{
"type": "pot_search_results",
"id": 208
},
{
"type": "pot_search_results",
"id": 209
},
{
"type": "pot_search_results",
"id": 210
}
],
"query_tree": null
},
"description": "hello example",
"query_text": "Heat",
"limit": 10,
"error": null,
"created_by": null,
"href": "http://blabla/bla/bla/pot/searches/25"
}
],
"linked": {
"pot_search_results": [
{
"links": {
"Pemash": {
"type": "pot_browse_contents",
"href": "http://blabla/bla/bla/pot/pots/5a267e98-0a12-4110-bac3-575439cb6097",
"id": "5a267e98-0a12-4110-bac3-575439cb6097"
},
"found_terms": [
{
"type": "pot_search_found_terms",
"id": 780
},
{
"type": "pot_search_found_terms",
"id": 781
},
{
"type": "pot_search_found_terms",
"id": 782
},
{
"type": "pot_search_found_terms",
"id": 783
},
{
"type": "pot_search_found_terms",
"id": 784
}
]
},
"id": 191,
"score": 13.765055790063306
},
{
"links": {
"Pemash": {
"type": "pot_browse_contents",
"href": "http://blabla/bla/bla/pot/pots/5a267e98-0a12-4110-bac3-575439cb6097",
"id": "5a267e98-0a12-4110-bac3-575439cb6097"
},
"found_terms": [
{
"type": "pot_search_found_terms",
"id": 785
},
{
"type": "pot_search_found_terms",
"id": 786
},
{
"type": "pot_search_found_terms",
"id": 787
},
{
"type": "pot_search_found_terms",
"id": 788
}
]
},
"id": 192,
"score": 10.669084946432259
},
{
"links": {
"Pemash": {
"type": "pot_browse_contents",
"href": "http://blabla/bla/bla/pot/pots/5a267e98-0a12-4110-bac3-575439cb6097",
"id": "5a267e98-0a12-4110-bac3-575439cb6097"
},
"found_terms": [
{
"type": "pot_search_found_terms",
"id": 789
},
{
"type": "pot_search_found_terms",
"id": 790
},
{
"type": "pot_search_found_terms",
"id": 791
},
{
"type": "pot_search_found_terms",
"id": 792
}
]
},
"id": 193,
"score": 10.669084946432259
},
NOW here is my VB.NET code:
Dim json As String = responseFromServer
Dim ser As JObject = JObject.Parse(json)
Dim data As List(Of JToken) = ser.Children().tolist() 'VisualStudio shows me error here that ToList is not a member of Newtonsoft.Json.Linq.JToken
Dim output As String = ""
So that i cannot save the children in the lists. Can you please tell me that how can I access the href elements in the json structure under "Linked" child with vb.net.
I shall be very thankful to you if you provide me one example to access the following line from Json Structure with vb.net code.
href": "http://blabla/bla/bla/pot/pots/5a267e98-0a12-4110-bac3-575439cb6097"
()ifChildrenis a property, not a method. I haven't used JObject in quite some time (I find Json.Net far more useful/flexible).System.Linqnamespace imported?Imports System.Linq?