Howto find a format specification for the .json file containing bookmarks.
My objective is to export a bookmarks folder to a file, then import it into the bookmarks for another browser. As far as I know, firefox does not provide this capability. I attempted to cut and paste the folder out of the .json backup file, and into it's counterpart for the target firefox instance, and the target firefox refused to import the modified input .json file. Also tried doing this with the .html export/import files.
If I could get a link to the docs which define the format for the .json file, that would be the preferable solution.
thanks in advance.
All Replies (7)
To open the Bookmarks Manager, press the Alt or F10 key bring up the tool bar, and select Bookmarks. Hot key is <Control>(Mac=<Command>) <Shift> B.
Once the window is open, at the top of the page, press the button labeled Import and Backup. Select Export Bookmarks To HTML, and follow the prompts and save it to a HTML file. Copy the file to another computer. Repeat the instructions above, BUT select Import Bookmarks From HTML,
You can export the bookmarks to an HTML file like posted above and edit this file to only keep the wanted bookmarks and folders.
If both Firefox instances are open at the same time then you can consider to use the clipboard and use Copy/Paste in the Bookmarks Manager (Library). You can add -no-remote to the command line to open another Firefox instance with its own profile and run multiple Firefox instances simultaneously.
This will only work for bookmarks and not for folders (you only get the folder id of as folder and not its content), so you would have to select all bookmarks in a folder and if necessary repeat this for multiple folders.
Firefox places this content on the clipboard as "text/x-moz-place" and as "text/unicode". Browser Console:
flavors = ["text/html","text/x-moz-place"]; flavor = flavors[1]; // use 0 for HTML format and 1 for JSON format var trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable); trans.init(null); trans.addDataFlavor(flavor); Services.clipboard.getData(trans, Services.clipboard.kGlobalClipboard); var str = {}; var strLength = {}; trans.getTransferData(flavor, str, strLength); if(str){pastedTxt = str.value.QueryInterface(Ci.nsISupportsString).data; var obj = new Object; obj.value = pastedTxt; Services.prompt.prompt(null, "Clipboard", pastedTxt.substr(0,1000), obj, null, {}) }
Endret
Thanks for the clipboard idea, but that doesn't solve the problem.
I tried lots of variations of the export-to-html solution, but in the end, when I attempted to import the .html file (after verifying that the folder I wanted to import was the only folder in the Bookmarks Menu section) firefox just sat there doing nothing, no warning message, no error message, just nothing.
The structure of the .json file seems obvious, but I have no way of knowing what data validation steps it's taking that cause it to report a very uninformative error (cant load) something like that. If someone can provide a copy or a link to the docs explaining what the various fields in the 'children' block mean, I can probably come up with a little utility that will enable export/import of a folder. Not going to waste my time trying to figure it out by trial and error.
open Firefox. Now open a file browser to where the file is. Move the file into the Firefox window. What happens?
Importing folders can be a problem. What kind of HTML structure are you using?
Folders are H3 tags. I think it should be this structure (not tested):
<!DOCTYPE NETSCAPE-Bookmark-file-1> <!-- This is an automatically generated file. It will be read and overwritten. DO NOT EDIT! --> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"> <TITLE>Bookmarks</TITLE> <H1>Bookmarks Menu</H1> <DL><p> <DT><H3 ADD_DATE="" LAST_MODIFIED="">FOLDER</H3> <DL><p> <DT><A HREF="httpt://xxxx" ADD_DATE="" LAST_MODIFIED="">BOOKMARK</A> </DL><p> </DL>
JSON format can only be used to replace the full bookmarks content unless you would go the clipboard way and copy bookmarks data to the clipboard and paste this data in the Bookmarks Manager (Library).
Thank you for your suggestion.
I understand that the .json file replaces the entire bookmarks data set. All I want to do is splice in a folder segment. It appears there is a sequence numbering system of some kind which is causing it to reject the reload.
If I could simply locate a format document for the .json file, I think it highly likely I could write an "insert folder segment" script which would enable me to move common folders into a common bookmarks .json file.
Thanks in advance for helping me answer the question I posted. (I tried all the other approaches, and they don't work. The HTML file I posted was based entirely on the original one exported by Firefox. I spliced in the new entries, tried to reload it, and it just sat there. No message, no nothing.)
Thanks in advance for any help on the .json format question.
BTW, apropos the HTML reload method... I did get it to work on one occasion, and by that I mean: I exported an HTML dataset, then removed one set of folders, spliced in another set from a different dataset, and when I imported it, it did work. However, on a subsequent attempt, using essentially the same procedure, it just sat there and did nothing. With no error message, it's really difficult to know what went wrong.