I’m developing a little Oracle reporting tool using Perl Dancer and Google Charts and I’ve hit an issue with JSON::XS output of number columns being quoted. Here’s a small example of the problem with the solution I found.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
use DBI; use JSON::XS; use strict; use warnings; my $dbh = DBI->connect('dbi:Oracle:',"$ARGV[0]", '') || die "Database connection not made: $DBI::errstr"; my $rs = $dbh->selectall_arrayref(q/select 'bob' name, 1 total from dual/); my @to_encode; foreach my $row (@$rs) { my $hash; $hash->{name} = shift @$row; $hash->{total} = $row; push @to_encode, $hash; } print encode_json(\@to_encode), "\n"; |
And now if we run this we get the number 1 with quotes – “1”. Thats […]