开发者

Is there a way to force quotation of numbers in JSON 1.x Perl module?

开发者 https://www.devze.com 2023-04-03 18:43 出处:网络
Test script use JSON; $\\ = \"\\n\"; my $big_number = \'12345678901234567890123456\'; print $big_number; print objToJson([$big_number]);

Test script

use JSON;
$\ = "\n";
my $big_number = '12345678901234567890123456';
print $big_number;
print objToJson([$big_number]);

Output (JSON 1.07, Perl 5.8.7)

12345678901234567890123456
[12345678901234567890123456]

Output (JSON 2.15, Perl 5.10.1)

12345678901234567890123456
[开发者_开发问答"12345678901234567890123456"]

I'd like to have strings representing numbers being quoted when using JSON 1.x the same way they are being quoted when using JSON 2.x. Is there any way to direct JSON 1.x Perl module to do this?


Set AUTOCONVERT to a false value, i.e.:

$JSON::AUTOCONVERT = 0;
0

精彩评论

暂无评论...
验证码 换一张
取 消