Output of this code depends on whether DEBUG environment is set or not. If set, result is [123]. If not to set, result is ["123"]. This is normal behaviour on Perl though, it sometimes causes unexpected JSON results.

There is a solution about this:

print encode_json([ $number + 0 ]);

This code always outputs [123]. But the code is a bit ugly and not readable at all.