Saving a data structure to a file...

Saving a data structure to a file...

I have a JSON data structure that I'm pulling in VIA an AJAX call.  What I want to be able to do is click a button/link and be able to save this data structure to disk, but I'm not really sure how to go about this.  I've been experimenting with the following:

The link has the following format "<a href='data:application/json, " + data_structure + "'>Click here!</a>"  I've been able to replace data_structure with text and /json to /rtf, which gives me a pop-up 'SaveAs' dialog box, and when I open the file, it has my text in there.  However, if I do data_structure, I just get [Objectobject], which is telling me that I'm passing in the object, but that's basically it, I need to expand it out?  I'm not really sure how to do that...

Which leads me to calling a perl script.  So I make an ajax call like so:

$.ajax({
      'dataType': 'JSON',
      'type': 'GET',
      'url': 'cgi-bin/save-text.pl',
      'async': false,
      'processData': false,
      'data': data_structure,
      'success': function(data) {
            alert(data);
      }
});

save-text.pl

print "Content-Type: text;\n\n";
print $ENV{QUERY_STRING};

This has given me mixed results.  If I create a data structure from scratch, say:

var pink = new Object();
pink['floyd'] = new Object();
pink['floyd'][0] = 'The Wall';
pink['floyd'][1] = 'Animals';

And pass this in as my data parameter, I get some good looking return pink['floyd'][0]=The+Wall&pink['floyd'][1]=Animals but if I try to pass in my JSON object, I can receive an error, undefined, just a blank pop-up box, or [Object object].  I think the problem is in the Perl script, but I'm not sure how I can access passed in hash values... like if I passed in my above data structure, how would I access that in a Perl script?

$ENV{QUERY_STRING}->{'pink'}{'floyd'}[0] doesn't seem to work... nor does it if I take the arrow away.

So I'm confused.  If someone could shed some light on this subject or possibly post a link to some page that'll help me out, then that'd be awesome.  Thanks!