I\'m trying to convert an array of numbers to json:
$json = to_json(\"numbers_array\" => \\@numbers_array); print $json;
but the output I\'m get
From the JSON documentation:
You can force the type to be a number by numifying it:
my $x = "3"; # some variable containing a string
$x += 0; # numify it, ensuring it will be dumped as a number
$x *= 1; # same thing, the choice is yours.
I would try something like this:
$json = to_json({numbers_array => [map { $_ + 0 } @numbers_array]});
print $json;