Subject: | String keys of hash which represent big integers are not quoted in anon_dump |
Perl preserves contents of big integer values in scalars when you don't
do math operations on them. In JavaScript there are no scalars: there
are numeric and string objects.
D::JS::A does not quote hash keys of structures so javascript machines
store their values as numbers. Their contents is then subject to change
if their values overcome the possibilities of numeric stashes of a
particular JS machine.
A temporary workaround for D::JS::A user would be:
- Switch to any of JSON implementations
- Change the logic of their javascript part by including string symbol
to hash key and then accessing it in their javascript by "hash[ 'x' +
integer_key ]".
Permanent workaround for D::JS::A would be quoting all keys of js
objects as suggested in bug 7183:
http://rt.cpan.org/Public/Bug/Display.html?id=7183.
Attached is a test script which could be used in a patch.
Subject: | string_key.t |
#!/usr/bin/perl
use strict;
our $hashref; BEGIN { $hashref = { '18810807140010000110' => 'value', }; }
use Test::Simple tests => scalar keys %$hashref;
use Data::JavaScript::Anon;
my $js = Data::JavaScript::Anon->anon_dump( $hashref );
ok $js =~ /['"]$_["']/, "$_ is quoted in dump string" for keys %$hashref;
#use Data::Dumper; warn '$js '.Dumper $js;