anon_hash_key returns undef if the key is a null string ('') or '0'.
This behaviour makes
anon_dump({'' => 1, '0' => 2, '00' => 3})
return
{ : 1, : 2, 00: 3 }
which, of course, is a syntax error.
The problem is on line 180 (according to cat -n) of Data/JavaScript/Anon.pm:
my $value = _STRING($_[0]) ? shift : return undef;
'' and '0' are perfectly valid hash keys both in Perl and JavaScript. If I'm not mistaken, Perl
hash keys are forced to be strings anyway, so is there any reason to validate $_[0] to make
sure it is a string? Could you not simply change that line to:
my $value = shift;
?