Reading "jsonlz4" bookmarkbackup files

User Help for Mozilla Firefox
User avatar
therube
Posts: 21685
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Re: Reading "jsonlz4" bookmarkbackup files

Post by therube »

For more of this look at my RAW notes in
http://www.imagemagick.org/Usage/info/data/json.txt
404 ?
Fire 750, bring back 250.
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 Pinball CopyURL+ FetchTextURL FlashGot NoScript
antofthy
Posts: 14
Joined: April 12th, 2012, 5:11 pm

Re: Reading "jsonlz4" bookmarkbackup files

Post by antofthy »

Applogies...

http://www.ict.griffith.edu.au/anthony/ ... a/json.txt

Fixing link in in the previosu post.
User avatar
dickvl
Posts: 54139
Joined: July 18th, 2005, 3:25 am

Re: Reading "jsonlz4" bookmarkbackup files

Post by dickvl »

Firefox has a "Pretty Print" button in the Scratchpad and also a "jsb" command (JavaScript beautifier) in the Developer Toolbar for files loaded via internet to format a JSON file for readability.
You can always open a JSON file in a tab and run some JavaScript via the Web Console to extract data or add line breaks at specific positions.
https://developer.mozilla.org/Tools/GCLI
https://developer.mozilla.org/Tools/Web_Console
antofthy
Posts: 14
Joined: April 12th, 2012, 5:11 pm

Re: Reading "jsonlz4" bookmarkbackup files

Post by antofthy »

Just a small update.

In bugzilla https://bugzilla.mozilla.org/show_bug.cgi?id=1209390#c4 Avi Halachmi announced that he used some firefox code to create a decompressor for the firefox compression

His code "dejonsonlz4" is available on GitHUB
https://github.com/avih/dejsonlz4/releases
jsonlz4
New Member
Posts: 1
Joined: June 17th, 2016, 3:08 pm

Re: Reading "jsonlz4" bookmarkbackup files

Post by jsonlz4 »

I HAVE THE ANSWER!


After spending hours and hours searching and searching how to decompress the stupid jsonlz4 file ](*,) so I could recover my bookmarks from a previous backup (after my computer crashed and windows had to be reinstalled).....

it turns out that you dont need to decompress it at all.

It all seemed so complicated, and there are a million answers out there, including crazy scripting and all kinds of crazy stuff. But its actually SUPER RIDICULOUSLY simple...

If you HAVE your stupid jsonlz4 file, here's ALL you have to do.....

Go to "view all bookmarks", go to "restore", and select the stupid jsonlz4 file. BOOM! BOOKMARKS RESTORED!!!!!!!!


I hope this post saves someone from the agony I had to go through, and the (what I thought was) complete devastation at the loss of my very important and enormous collection of bookmarks.

Lesson learned though.... I'll certainly be making a backup!
antofthy
Posts: 14
Joined: April 12th, 2012, 5:11 pm

Re: Reading "jsonlz4" bookmarkbackup files

Post by antofthy »

Yes that has been brought up quite a few times.. But the original problem of this topic was to.... Do it off line..

That is automatically without a GUI. That is without using the firefox browser itself. Also it was a dig at the developers for actually using a format that can not be decoded using standard thrid party tools allowing the recovery of information to be future proofed!

Actually if anything I prefer... Plain TEXT... Because regardless of what software comes and what software goes, I can still get information I need from it, 30 years later!
RegX
Posts: 3
Joined: July 18th, 2011, 1:11 pm

Re: Reading "jsonlz4" bookmarkbackup files

Post by RegX »

jsonlz4 wrote: If you HAVE your stupid jsonlz4 file, here's ALL you have to do.....

Go to "view all bookmarks", go to "restore", and select the stupid jsonlz4 file. BOOM! BOOKMARKS RESTORED!!!!!!!!
This doesn't work for me - when I select the jsonlz4 file I get a message 'Unsupported File Type'.

However, I am currently running my laptop by booting from a Linux CD (the installed Windows OS is broken) and I suspect that the version of Firefox on the CD (31.0) predates Firefox's use of the jsonlz4 file. If someone could confirm this I would be grateful! If so, when I am ready to install Linux I will then be able to upgrade to a new version of Firefox which will hopefully solve this problem.
User avatar
the-edmeister
Posts: 32249
Joined: February 25th, 2003, 12:51 am
Location: Chicago, IL, USA

Re: Reading "jsonlz4" bookmarkbackup files

Post by the-edmeister »

Firefox 32 was the "Target Milestone" for that file format in Firefox, per the Bug report,
https://bugzilla.mozilla.org/show_bug.cgi?id=818587

But considering this thread was started by a user who posted with Firefox 33.0, it's fairly safe to assume that may have been when it arrived.

But whichever it was, it wasn't in Firefox 31.


.
A mind is a terrible thing to waste. Mine has wandered off and I'm out looking for it.
User avatar
BruceAWittmeier
Posts: 3076
Joined: June 9th, 2008, 10:53 am
Location: Near 37.501685 -80.147967

Re: Reading "jsonlz4" bookmarkbackup files

Post by BruceAWittmeier »

Don't know if the OP is still visiting but what you might be able to do is:
- install an older copy of Firefox
- import the .jsonlz4 file
- export the bookmarks file to an .html
- import to the newer copy of Firefox as HTML

Just need a copy that will accommodate the specific file extensions. HTML has always work in all versions - unless corrupted.
I often take a long windy road to my destination. Upon arrival, I wonder how I missed the shortcut.
antofthy
Posts: 14
Joined: April 12th, 2012, 5:11 pm

Re: Reading "jsonlz4" bookmarkbackup files

Post by antofthy »

BruceAWittmeier wrote:Don't know if the OP is still visiting but what you might be able to do is:
- install an older copy of Firefox
- import the .jsonlz4 file
- export the bookmarks file to an .html
- import to the newer copy of Firefox as HTML

Just need a copy that will accommodate the specific file extensions. HTML has always work in all versions - unless corrupted.
Again... as mentioned clearly in the original post... It must be done in an AUTOMATIC way, without human interaction. so NO Firefox!

In any case the problem was resolved two factors. 1/ I moved to Chrome (this was a major factor) 2/ someone wrote a utility to decode the weird LZ compression.
Tijitek
Posts: 43
Joined: August 13th, 2004, 11:18 am
Location: Ireland

Re: Reading "jsonlz4" bookmarkbackup files

Post by Tijitek »

I just stumbled on this thread while I was looking for a way to analyse and compare old bookmark files. I could not believe that the Firefox developers would come up with a private non-standard binary file format for this. It reminds me of the horrendous Mork text format ( https://en.wikipedia.org/wiki/Mork_%28file_format%29 ) that was (is it still?) used by Thunderbird for address books. We should not need special tools to decode data that can easily be stored in standard formats.

In my own case, I ended up using the Python code posted at https://gist.github.com/Tblue/62ff47bef7f894e92ed5 (thanks!), to which I needed to add "from __future__ import print_function" at the start to keep Python 2.7 happy. The first file uncompressed from 59.5 kB to 59.8 kB. Was it really worth putting us through all these hoops for 300 bytes?
jwdevel
New Member
Posts: 1
Joined: November 4th, 2016, 3:20 pm

Re: Reading "jsonlz4" bookmarkbackup files

Post by jwdevel »

Tijitek wrote:In my own case, I ended up using the Python code posted at https://gist.github.com/Tblue/62ff47bef7f894e92ed5 (thanks!)
Spooky, I was just going through the same hoops and about to post a similar reply (:

In my case, I found https://gist.github.com/mnordhoff/25e42a0d29e5c12785d0
Clear from the author's comments that they weren't too happy about the situation either...

For anyone wanting to understand the nonsense, here's the main thing, from a comment in there:
# In short, 'mozLz40\0' magic number + uint32le length + lz4 data.

Another one: https://github.com/avih/dejsonlz4
That one linked from a relevant mozilla bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1209390
NanM
Posts: 182
Joined: September 16th, 2008, 1:04 am
Location: SW WAustralia

Re: Reading "jsonlz4" bookmarkbackup files

Post by NanM »

I use the dev code - can't remember who wrote it, but they're one
of the longtime Firefox extension devs - directly in the browser
console for quick hacks of search file. Works fine for any lz4 file,
including the bookmarks backup ones.

Code: Select all

function decompress() {
  Task.spawn(function() {
    let cacheFilePath = OS.Path.join(OS.Constants.Path.profileDir, "search.json.mozlz4");
    let bytes = yield OS.File.read(cacheFilePath, {compression: "lz4"});
    let data = new TextDecoder().decode(bytes);
    let jsonFilePath = OS.Path.join(OS.Constants.Path.profileDir, "search.json");
    OS.File.writeAtomic(jsonFilePath, data);
  });
}
decompress();
And the reversing code:

Code: Select all

function compress() {
  Task.spawn(function() {
    let jsonFilePath = OS.Path.join(OS.Constants.Path.profileDir, "search.json");
    let bytes = yield OS.File.read(jsonFilePath);
    let data = new TextDecoder().decode(bytes);
    let cacheFilePath = OS.Path.join(OS.Constants.Path.profileDir, "search.json.mozlz4_new");
    OS.File.writeAtomic(cacheFilePath, data, {compression: "lz4"});
  });
}
compress();
morat
Posts: 6394
Joined: February 3rd, 2009, 6:29 pm

Re: Reading "jsonlz4" bookmarkbackup files

Post by morat »

Scratchpad doesn't evaluate expressions in a sandbox anymore so it's best to wrap your code.

Code: Select all

(function() {

var gBrowser = "abracadabra";

})();
http://forums.mozillazine.org/viewtopic ... &t=2335397
http://forums.mozillazine.org/viewtopic ... p=13742825

Mozilla never bothered to document the change when they removed the sandbox.

@NanM

Thanks for posting that.

Code: Select all

type search.json | python -m json.tool > search.pretty_print.json
:)
Post Reply