G
gaxjyxq
Guest
How to remove the json object (dateadded, guid, id, name, type, url) by the key (id). For example i need to remove the object (the Bold and italic part) by the id=10.
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": "https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vbgeneral"
} ],
"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 code is below
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
Dim listBookmarkBarChild As List(Of Child) = GetbookmarkbarBookmarkBarChildren(jsonTxt)
Dim listOtherChild As List(Of Child) = GetbookmarkbarOtherChildren(jsonTxt)
Dim merged As New List(Of Child)()
merged.AddRange(listBookmarkBarChild)
merged.AddRange(listOtherChild)
For Each result As Child In merged
Dim line As String = result._id & " " & result._dateadded & " " & result._guid & " " & result._name & " " & result._type & " " & result._url
ListBox1.Items.Add(line)
Next
End Sub
Public Function GetbookmarkbarBookmarkBarChildren(sender As String) As List(Of Child)
Dim json As JObject = JObject.Parse(sender)
Dim children As JToken = json("roots")("bookmark_bar")("children")
Dim returnChildren As New List(Of Child)()
For Each child As JObject In children
returnChildren.Add(child.ToObject(Of Child)())
Next
Return returnChildren
End Function
Public Function GetbookmarkbarOtherChildren(sender As String) As List(Of Child)
Dim json As JObject = JObject.Parse(sender)
Dim children As JToken = json("roots")("other")("children")
Dim returnChildren As New List(Of Child)()
For Each child As JObject In children
returnChildren.Add(child.ToObject(Of Child)())
Next
Return returnChildren
End Function
Public Class Child
Public Sub New(date_added As String, guid As String, id As String, name As String, type As String, url As String)
_dateadded = date_added
_guid = guid
_id = id
_name = name
_type = type
_url = url
End Sub
Public Property _dateadded() As String
Public Property _guid() As String
Public Property _id() As String
Public Property _name() As String
Public Property _type() As String
Public Property _url() As String
End Class
Continue reading...
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": "https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vbgeneral"
} ],
"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 code is below
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
Dim listBookmarkBarChild As List(Of Child) = GetbookmarkbarBookmarkBarChildren(jsonTxt)
Dim listOtherChild As List(Of Child) = GetbookmarkbarOtherChildren(jsonTxt)
Dim merged As New List(Of Child)()
merged.AddRange(listBookmarkBarChild)
merged.AddRange(listOtherChild)
For Each result As Child In merged
Dim line As String = result._id & " " & result._dateadded & " " & result._guid & " " & result._name & " " & result._type & " " & result._url
ListBox1.Items.Add(line)
Next
End Sub
Public Function GetbookmarkbarBookmarkBarChildren(sender As String) As List(Of Child)
Dim json As JObject = JObject.Parse(sender)
Dim children As JToken = json("roots")("bookmark_bar")("children")
Dim returnChildren As New List(Of Child)()
For Each child As JObject In children
returnChildren.Add(child.ToObject(Of Child)())
Next
Return returnChildren
End Function
Public Function GetbookmarkbarOtherChildren(sender As String) As List(Of Child)
Dim json As JObject = JObject.Parse(sender)
Dim children As JToken = json("roots")("other")("children")
Dim returnChildren As New List(Of Child)()
For Each child As JObject In children
returnChildren.Add(child.ToObject(Of Child)())
Next
Return returnChildren
End Function
Public Class Child
Public Sub New(date_added As String, guid As String, id As String, name As String, type As String, url As String)
_dateadded = date_added
_guid = guid
_id = id
_name = name
_type = type
_url = url
End Sub
Public Property _dateadded() As String
Public Property _guid() As String
Public Property _id() As String
Public Property _name() As String
Public Property _type() As String
Public Property _url() As String
End Class
Continue reading...