##
my $js = WWW::Mechanize::PhantomJS->new(launch_exe=> 'C:/prog/phantomjs/bin/phantomjs.exe');
#or
#my $js = WWW::Mechanize::Chrome->new(report_js_errors=>1);
$js->get_local("hello.html");
my ($val, $type) = $js->eval_in_page('JSON.stringify(window.leg);');
#or
#my ($val, $type) = $js->eval_in_page('JSON.stringify(leg);');
#or
#my ($val, $type) = $js->eval_in_page('to_json()');
print "val: ", Dumper($val), "type: $type\n";