Subject: | Encoded JSON integers become strings |
Tested with the following script which compares regular JSON to JSON::Color:
----
#!/bin/env perl
use strict;
use warnings;
use JSON::MaybeXS qw(decode_json);
use JSON::Color qw(encode_json);
chomp( my $input = <STDIN> );
my $ref = decode_json( $input );
my $json = JSON::MaybeXS->new;
print $json->pretty(1)->canonical(1)->encode( $ref ) . "\n";
print encode_json( $ref, { pretty => 1, sort_by => sub { $JSON::Color::a cmp $JSON::Color::b } } ) . "\n";
----
Input:
echo '{"subtotal":21.40,"quantity":2,"description":"Foo"}' | my-script
Output:
{
"description" : "Foo",
"quantity" : 2,
"subtotal" : 21.4
}
{
"description": "Foo",
"quantity": "2",
"subtotal": "21.4"
}
first is regular JSON, second is JSON::Color.