G
gaxjyxq
Guest
Hello,
My Chrome bookmarks content is below
{
"checksum": "6bf34f912e074d6dc26a92ae6b9c7eff",
"roots": {
"bookmark_bar": {
"children": [ {
"date_added": "13224378541763350",
"guid": "8711febe-419c-4da8-bfdf-e871a4185c0c",
"id": "9",
"name": "Yahoo",
"type": "url",
"url": "Yahoo"
}, {
"date_added": "13224378601163246",
"guid": "92b9e1b8-935a-473e-8609-36f681fddd44",
"id": "10",
"name": "Msdn forums - Visual Basic",
"type": "url",
"url": "Msdn forums - Visual Basic"
} ],
"date_added": "13209171729527352",
"date_modified": "13224378887233972",
"guid": "00000000-0000-4000-A000-000000000002",
"id": "1",
"name": "Bookmark Bar",
"type": "folder"
},
"other": {
"children": [ {
"date_added": "13224378887233972",
"guid": "46c75cfb-557b-4147-a7d2-8a46bfb038ae",
"id": "11",
"name": "Latest Updates - CodeProject",
"type": "url",
"url": "Latest Updates - CodeProject"
}, {
"date_added": "13224378948095465",
"guid": "4eb3765b-2227-4d61-a860-c50432a73fc6",
"id": "13",
"name": "Windows Forum",
"type": "url",
"url": "Windows Forum"
} ],
"date_added": "13209171729527373",
"date_modified": "13224378948095465",
"guid": "00000000-0000-4000-A000-000000000003",
"id": "5",
"name": "Other",
"type": "folder"
},
"synced": {
"children": [ ],
"date_added": "13209171729527374",
"date_modified": "0",
"guid": "00000000-0000-4000-A000-000000000004",
"id": "7",
"name": "Mobile device bookmarks",
"type": "folder"
}
},
"version": 1
}
The C# code can deserialize the json string above.
List<Child> getbookmarkbar_children(string jsontxt)
{
dynamic json = Newtonsoft.Json.JsonConvert.DeserializeObject(jsontxt);
dynamic children = json.roots.bookmark_bar.children;
List<Child> returnchildren = new List<Child>();
foreach (Newtonsoft.Json.Linq.JObject child in children)
{
returnchildren.Add(child.ToObject<Child>());
}
return returnchildren;
}
But I want to covert to VB.NET, for the keyword "dynamic" in C#, I add the "Option Strict Off", and use 'Object' to replace 'dynamic', but it will not work, can anyone deserialize json string using VB.NET?
Private Function getbookmarkbar_children(ByVal jsontxt As String) As List(Of Child)
Dim json As Object = Newtonsoft.Json.JsonConvert.DeserializeObject(jsontxt)
Dim children As Object = json.roots.bookmark_bar.children
Dim returnchildren As New List(Of Child)()
For Each child As Newtonsoft.Json.Linq.JObject In children
returnchildren.Add(child.ToObject(Of Child)())
Next child
Return returnchildren
End Function
Continue reading...
My Chrome bookmarks content is below
{
"checksum": "6bf34f912e074d6dc26a92ae6b9c7eff",
"roots": {
"bookmark_bar": {
"children": [ {
"date_added": "13224378541763350",
"guid": "8711febe-419c-4da8-bfdf-e871a4185c0c",
"id": "9",
"name": "Yahoo",
"type": "url",
"url": "Yahoo"
}, {
"date_added": "13224378601163246",
"guid": "92b9e1b8-935a-473e-8609-36f681fddd44",
"id": "10",
"name": "Msdn forums - Visual Basic",
"type": "url",
"url": "Msdn forums - Visual Basic"
} ],
"date_added": "13209171729527352",
"date_modified": "13224378887233972",
"guid": "00000000-0000-4000-A000-000000000002",
"id": "1",
"name": "Bookmark Bar",
"type": "folder"
},
"other": {
"children": [ {
"date_added": "13224378887233972",
"guid": "46c75cfb-557b-4147-a7d2-8a46bfb038ae",
"id": "11",
"name": "Latest Updates - CodeProject",
"type": "url",
"url": "Latest Updates - CodeProject"
}, {
"date_added": "13224378948095465",
"guid": "4eb3765b-2227-4d61-a860-c50432a73fc6",
"id": "13",
"name": "Windows Forum",
"type": "url",
"url": "Windows Forum"
} ],
"date_added": "13209171729527373",
"date_modified": "13224378948095465",
"guid": "00000000-0000-4000-A000-000000000003",
"id": "5",
"name": "Other",
"type": "folder"
},
"synced": {
"children": [ ],
"date_added": "13209171729527374",
"date_modified": "0",
"guid": "00000000-0000-4000-A000-000000000004",
"id": "7",
"name": "Mobile device bookmarks",
"type": "folder"
}
},
"version": 1
}
The C# code can deserialize the json string above.
List<Child> getbookmarkbar_children(string jsontxt)
{
dynamic json = Newtonsoft.Json.JsonConvert.DeserializeObject(jsontxt);
dynamic children = json.roots.bookmark_bar.children;
List<Child> returnchildren = new List<Child>();
foreach (Newtonsoft.Json.Linq.JObject child in children)
{
returnchildren.Add(child.ToObject<Child>());
}
return returnchildren;
}
But I want to covert to VB.NET, for the keyword "dynamic" in C#, I add the "Option Strict Off", and use 'Object' to replace 'dynamic', but it will not work, can anyone deserialize json string using VB.NET?
Private Function getbookmarkbar_children(ByVal jsontxt As String) As List(Of Child)
Dim json As Object = Newtonsoft.Json.JsonConvert.DeserializeObject(jsontxt)
Dim children As Object = json.roots.bookmark_bar.children
Dim returnchildren As New List(Of Child)()
For Each child As Newtonsoft.Json.Linq.JObject In children
returnchildren.Add(child.ToObject(Of Child)())
Next child
Return returnchildren
End Function
Continue reading...