Subject: | Wrong decision about perl datatypes |
Below is example when perl treats scalar as string ("042"), and even JSON::XS converts it to JSON string, but JavaScript::Duktape::XS treats it as a number.
I think that behaviour is not consistent with perl.
$ cat 2.pl
use strict;
use warnings;
use JavaScript::Duktape::XS;
use JSON::XS;
my $vm = JavaScript::Duktape::XS->new();
my $x = "042";
die if $x == 13;
print "orig: $x\n";
print "orig json ". encode_json({x => $x})."\n";
$vm->set('xx', $x);
print "result: ".$vm->get('xx')."\n";
print "result json: ".encode_json({x => $vm->get('xx')})."\n";
$ perl 2.pl
orig: 042
orig json {"x":"042"}
result: 42
result json: {"x":42}