Is there a way to convert the compressed jsonlz4 files to json?
Hi, is it possible to know how to properly restore a bookmarks session via jsonlz4 file? Firefox lost all of my bookmarks and when trying to restore them using the recovery session with the last jsonlz4 file the process simply does not end, starts but after couple hours is still running, with continuos warnings of scripts busy, or stopped responding. Is there a way to do it properly? Or a tool to convert the compressed jsonlz4 to json, maybe html. Thank you.
الحل المُختار
Well gentlemen: I definitely gave up; whatever the reason, the issue is not resolvable. I stay with the old html bookmark, necessarily. Thanks for the efforts jscher and co-rel, and goodbye.
Read this answer in context 👍 1All Replies (18)
Sorry to hear that Firefox can't process the file. Is it enormous?
I did find a post about how to use Firefox's developer tools to decompress the lz4-compressed file back to plain JSON. This would make it easier to analyze whether the JSON itself is invalid. I haven't tried it myself, or should I say, I started running the code and immediately realized I didn't know where my .jsonlz4 file was so I had to cancel out:
http://forums.mozillazine.org/viewtopic.php?p=14111285#p14111285
Here's a variation of that script which uses a file picker, which may make it a little easier. The converted file will be saved alongside the compressed one in the same folder.
/* NOTE: BEFORE RUNNING THIS SCRIPT, CHECK THIS SETTING: Type or paste about:config into the address bar and press Enter Click the button promising to be careful In the search box type devt and pause while Firefox filters the list If devtools.chrome.enabled is false, double-click it to toggle to true Paste this entire script into the command line at the bottom of the Browser Console (Windows: Ctrl+Shift+j) Then press Enter to run the script. A file picker should promptly open. */ // Set up file chooser var fp = Components.classes["@mozilla.org/filepicker;1"] .createInstance(Components.interfaces.nsIFilePicker); fp.init(window, "Open File", Components.interfaces.nsIFilePicker.modeOpen); fp.appendFilter("Bookmark Backup Files", "*.jsonlz4"); // Call file choose, proceed if a file was chosen if (fp.show() == Components.interfaces.nsIFilePicker.returnOK) { var file = fp.file; // Check that file can be used if (file.exists() && file.isFile() && file.isReadable()) { var oldfile = fp.file.path; // Construct output file name var newfile = oldfile.replace(".jsonlz4", "_converted.json"); // See: http://forums.mozillazine.org/viewtopic.php?p=14111285#p14111285 var {utils:Cu} = Components; Cu.import("resource://gre/modules/Task.jsm"); Cu.import("resource://gre/modules/osfile.jsm"); function decompressBookmarksFile(oFilePath,nFilePath){return Task.spawn(function* () {var jsonString = yield OS.File.read(oFilePath,{ compression: "lz4" });yield OS.File.writeAtomic(nFilePath, jsonString);})} decompressBookmarksFile(oldfile,newfile); } }
Maybe add a "Saved as" confirmation via console.log(newfile).
decompressBookmarksFile(oldfile,newfile); console.log("Saved as:"+ newfile);
Yes it's a big file. The code 'apparently' works (apart from a series of reference and type errors), jsonlz4 converted to json, but the recovery still gives me script errors: is there a way to verify if the file is invalid? Or a way to convert this json format to the more handy html, that never gave me a problem in restoring the bookmarks. And moreover: why use the problematic json/jsonlz4 extension (I read issues similar to mine alongside the web)? It's a DRAMA when you lose all of your bookmarks because of some coder's wrong choice.
I think the reason for the JSON format is that the traditional HTML format which became an informal standard in the 1990s does not capture all of the relevant data about your bookmarks, such as tags. The problem isn't so much using JSON or compressing it, but that every so often the file becomes corrupted for some reason, possible because a bookmark included a title or description containing an unexpected character, or the database from which the bookmarks are extracted has become corrupted. If Mozilla knew, someone could fix it going forward.
At this point, since you have JSON, there are tools online to "validate" that it is in the correct structural format. I have seen links for that in past threads but I don't recall trying them myself: https://support.mozilla.org/questions/1054932#answer-711872. I don't know whether the validators can repair the file, but they might indicate where there is a stray or missing comma, bracket, etc.
Unfortunately the json validators I tried are useless, probably because my file is too lage. At this point after two whole days trying recovering the bookmarks, with poor sleeping, headache, anger and frustration I almost gave up: I acknowledge the json/jsonlz4 extension is a (intentional?) useless waste of time and that there's no way to operate this thing the right way. No way. At this very moment I'm waiting for firefox to open its window, watching in task manager the idle firefox recovering process that I started six hours ago. I call this a shame, that's not the right way to code I think. So thank you for the help, so long to my bookmarks and after a long sympathy for firefox maybe it's time to consider a new browser - unless you have the definitive solution, haven't you?
How large is the uncompressed JSON file and how many bookmark items are in the file according to its file name?
- bookmarks-YYYY-MM-DD_<item count>_<hash>.json
You can open the file in the Scratchpad (Firefox/Tools > Web Developer). Click the "Pretty Print" button to format the file for readability and possibly save the file under a different name.
Json 30 Mb, one hundred thousand items. It's a very old bookmark, years of browsing. I don't know if opening the file in scratchpad is a good move, but I may try if you think so.
Opening such a large file may take some time, so make sure that you do not have important links open in tabs or use a separate profile just in case to prevent blocking Firefox.
Script errors again. Anyway, late here, keep trying next morning, I'll let you informed.
Oh my: I tried installing an old html bookmark and now firefox gives script errors also here, even in safe mode with no add-ons running. Moreover the same happens trying importing bookmarks from Google Chrome. The hell is happening with this browser??
You can extend the time for scripts to be considered unresponsive during this import process if that will make it easier... it won't actually make the import/restore faster.
In about:config you would increase the value for dom.max_chrome_script_run_time which defaults to 20 (seconds).
(I believe setting this preference to 0 allows Firefox to run the script up to 2147483647 seconds, which may be longer than you plan to own your computer... something like 28800 (8*60*60 = 8 hours) might be more along the lines of what you need.)
It's not the timing: firefox for some reason simply does not allow recovering the bookmarks, in every format they come. I should need a very new installation of the browser I guess, but even completely uninstalling firefox is not possible, unless I format the Windows os. I don't know, this thing is craziness.
After intalling firefox 35.0.1 (having tried ff 40 beta and 40 beta 64bit, and ff 31, with no success) and changing the dom.max_chrome_script_run_time to 1000, the html file has been accepted; upgraded to ff 39 and boomarks still there. The jsonlz4 still gives script error. Now I don't really know if I want to try increasing the dom.max_chrome_script_run_time again too verify if even the json/jsonlz4 works.
If your HTML backup was complete, then it sounds as though experimenting with the JSON file would only be in the interest of science. Perhaps someone with a deep interest could create some other files of intermediate sizes for testing, since 100,000 bookmarks may be more than anyone ever expected (speaking as someone with about 9000 in his backup).
Firefox can get set to generate an HTML export of bookmarks at shutdown. It is overwritten (it doesn't create dated backups), but if you set Firefox to store it in a location you normally back up, perhaps that would be helpful. For more info, see: https://support.mozilla.org/questions/1062318#answer-729111
Yes I'm aware about the possibility of an automatic html backup, but a file so big wants minutes for being written and I usually close firefox several times over the day to free the ram it uses. Would be annoying. The html of course isn't complete, it's not as recent as the json; but something is better than nothing and after three days trying and trying I can say this one doesn't recover at all, even with dom.max_chrome_script_run_time set to 10000, so I guess I must consider it gone along with this silly kind of recovery session via jsonlz4. It's useless, at least for my pc. At this point I need a good json viewer to try estracting the links lost, but I'm raging: this issue is not acceptable.
Only automatically created JSON backups are compressed. If you create a JSON backup manually then you get an uncompressed .json backup. A difference is that an HTML backup is created when you close Firefox and an automatic JSON backup is created when you start Firefox or when Firefox detects that Firefox hasn't been restarted for some time.
Both should contain a full set of bookmarks, but a JSON backup includes tags and annotations, so is more complete.
الحل المُختار
Well gentlemen: I definitely gave up; whatever the reason, the issue is not resolvable. I stay with the old html bookmark, necessarily. Thanks for the efforts jscher and co-rel, and goodbye.