Is it actually a problem that JSON is making 123.1 into a '123.1' as it goes into mongodb? If you are pulling it back out again in perl, then it shouldn't matter.
If it does matter, then the workaround is going to be dependant on what library does the serialization. If it is JSON.pm, then what you are doing ( add zero, or multiply by 1 ) should make sure that things are encoded as numbers.
It appears that JSON.pm is doing things correctly.
use JSON::PP;
use JSON::XS;
use JSON::Syck;
my $x = 123.1;
my $y = '123.10';
my $z = $y + 0;
my $h = { x => $x, y => $y, z => $z };
print JSON::PP::encode_json($h) . "\n";
print JSON::XS::encode_json($h) . "\n";
print JSON::Syck::Dump($h) . "\n";
__END__
{"y":"123.10","x":123.1,"z":123.1} #JSON::PP
{"y":"123.10","x":123.1,"z":123.1} #JSON::XS
{"y":123.10,"x":123.1,"z":123.1} #JSON::Syck ( seems to do $y wrong/
+differently )
|