Chrome's bookmarks file is a json file with the below hierarchy:
Code: Select all
{
"checksum": "688c795c82968728c5d81a50d8dc10f0",
"roots": {
"bookmark_bar": {
"children": [ {
"date_added": "13319166277591147",
"id": "11",
"meta_info": {
"last_visited_desktop": "13319166277591334"
},
"name": "Yandex",
"type": "url",
"url": "https://yandex.com/"
} ],
"date_added": "13319166157194773",
"date_modified": "13319166284776317",
"id": "1",
"name": "Bookmarks bar",
"type": "folder"
},
"other": {
"children": [ {
"children": [ {
"date_added": "13319166167629700",
"id": "6",
"meta_info": {
"last_visited_desktop": "13319166167629868"
},
"name": "Google",
"type": "url",
"url": "https://www.google.com/"
}, {
"children": [ {
"date_added": "13319166209639295",
"id": "9",
"meta_info": {
"last_visited_desktop": "13319166209639443"
},
"name": "Bing",
"type": "url",
"url": "https://www.bing.com/?toHttps=1&redig=1A29E89D0713485780A5D1DA819339B5"
} ],
"date_added": "13319166186436779",
"date_modified": "13319166247271113",
"id": "7",
"name": "FOLDER2",
"type": "folder"
} ],
"date_added": "13319166167627517",
"date_modified": "13319166186436991",
"id": "5",
"name": "FOLDER1",
"type": "folder"
}, {
"date_added": "13319166247271113",
"id": "10",
"meta_info": {
"last_visited_desktop": "13319166247271383"
},
"name": "DuckDuckGo",
"type": "url",
"url": "https://duckduckgo.com/"
} ],
"date_added": "13319166157194783",
"date_modified": "13319166277591147",
"id": "2",
"name": "Other bookmarks",
"type": "folder"
},
"synced": {
"children": [ ],
"date_added": "13319166157194784",
"date_modified": "0",
"id": "3",
"name": "Mobile bookmarks",
"type": "folder"
}
},
"version": 1
}
i am not familiar with objects and recursive loops, and so far this is the code i came up with using the json2ahk library:
Code: Select all
#Include JSON AHK1.ahk
FileRead, textv, bookmarks
Array:= Jxon_Load(textv)
Search(Array)
Return
Search(Array) {
for each, obj in Array
{
msgbox key: %each%
if !IsObject(obj)
msgbox value: %obj%
else
{
msgbox RECURSE
search(obj)
}
}
}
the problem is that each loop creates a new loop and so on, and i lose track of which values of bookmarks (url/title) belong to which children object, which corresponds to the folder which contains the bookmarks. also the object that provides information (folder name) about the children object comes in the end after the bookmarks properties.
can someone help me with this? how to create the pairs url-title-folder_name in their corresponding children groups? i have found some guides in stackoverflow to export the bookmarks, but they use python or the jq app. i would like to do this with AHK.