Format of compressed JSON

    Dec 30 2011 | 12:33 pm
    Is the "copy compressed" format documented anywhere or does anyone have a conversion function that produces the original JSON that they'd be willing to share? It doesn't look like a standard zip format unless it has also been b64 encoded as well.
    I'd like to look at converting posted patches into a visual view (as an experimental but possibly useful project to test some interesting languages that generate JavaScript as their target)

    • Jan 05 2012 | 10:16 pm
    • Jan 06 2012 | 7:48 am
      Why not use Max to convert?
    • Jan 06 2012 | 11:31 am
      The idea was to be able to get a graphic view of a patch that has been posted to the forum so that when someone is reading a post with their web browser, there could be some JavaScript that could convert that compressed patch into a visual view on the fly without having to first paste it into Max, which might not be even be available. For example, I read most of thee posts from an iPad.
      I had suggested this at the Brooklyn conference.
    • Jan 06 2012 | 7:01 pm
      I'd love to see this eventually. Even if it wasn't a working patch, I'd love to be able to view patches on a mobile device.
      You should ask if the good people of Cycling74 would include the dict.serialize example in their Max 6 SDK so you can figure out how to decompress JSON.
    • Jan 06 2012 | 8:26 pm
      Hi dhj,
      Our compressed JSON uses a non-standard variation of base64 encoded gzip'ed JSON. Your question is timely as you may have noticed that our forum compressed patch now reports the version number of the patch. It does this by decoding, decompressing, and searching through the JSON.
      We aren't going to put a lot of efforts into supporting this code, but I include for your reference and experimentation the relevant code excerpts from our forum web page (view source).
      var codeGZ64 = $(this).text();
      var togglename ="pastedcode", "toggle");
      var patchout = '-----------end_max5_patcher-----------';
      // we need to cut out the begin and end patcher text
      // however, since the base64 encoding of JUCE puts on an additional
      // number and "." at the beginning AND we need to cut this off, we
      // will search here for the first period and not the 'begin_max5_patcher' text
      var inpos = codeGZ64.indexOf(".");
      var outpos =;
      codeGZ64 = codeGZ64.slice( inpos+1, outpos);
      try {
          // the b64 decode algo inside of JXG will try to clean up the string, removing
          // all white chars and other chars that are not part of our codex.
          var code = JXG.decompress( codeGZ64 );
          // let's check the code to see if it contains any max6 objs
          // we will also check for any patcher objs with version info
          // if so, lets update the patcher text
          var obj = JSON.parse(code);
          var max_version = getMaxVersion(obj);
          $("#" + togglename + " #maxversion" ).text(max_version);
          // uncomment to see the JSON above the gzip'ed code
          //$(this).text( code + "n" + codeGZ64);
      } catch (err) {
          //alert("could not decompress pasted Max patch code. Error: " + err);
          $("#" + togglename + " #maxversion" ).text("5");
      We have a variety of ideas of what this opens to the door to, including what you mention for previewing patchers, searching patchers, data-mining for auto-tagging, etc. We have no commitments to what or when any additional forum patcher features might be coming, so I would encourage you to have fun with this stuff.
      Keep in mind after this, you're basically on your own, but I think it should give you enough to get access to the uncompressed JSON within a browser.
      Cheers, Joshua
    • Jan 06 2012 | 8:48 pm
      Very cool --- thanks --- as I find time, I'd like to play around with this --- good excuse to get up to speed with JavaScript
    • Jan 07 2012 | 6:15 pm
      I'm up for some of this too, been looking in to it for a while, lots of cool stuff that could be done!