Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed support for Perl 5.10 and 5.12
  • Loading branch information
kraih committed May 12, 2014
1 parent 44056e2 commit 6ed79b5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/Mojo/JSON.pm
@@ -1,6 +1,7 @@
package Mojo::JSON;
use Mojo::Base -base;

use B;
use Carp 'croak';
use Exporter 'import';
use Mojo::Util;
Expand Down Expand Up @@ -262,15 +263,14 @@ sub _encode_value {
return 'null' unless defined $value;

# Number
my $num = $value;
{
no warnings 'numeric';
my $num = $value;
$num += 0;
my $flags = B::svref_2object(\$value)->FLAGS;
return $num
if $flags & (B::SVp_IOK | B::SVp_NOK) && $num eq $value && $num * 0 == 0;
}
my $str = $value;
$str .= '';
return $num
if ($value ^ '0') ne ($str ^ '0') && $num eq $str && $num * 0 == 0;

# String
return _encode_string($value);
Expand Down

0 comments on commit 6ed79b5

Please sign in to comment.