From f62cb73dc058b34ee434f344eb964b092bc29f49 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 8 Jun 2005 20:23:44 +0000 Subject: [PATCH] removed number overloads removed number casting, just using string for numbers git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@334 9efc2488-bf62-4759-914b-345cdb29e865 --- src/perlmods/JSON.pm | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/perlmods/JSON.pm b/src/perlmods/JSON.pm index 5e4392e..cbb03f7 100644 --- a/src/perlmods/JSON.pm +++ b/src/perlmods/JSON.pm @@ -4,16 +4,8 @@ sub new { my $x = shift || $class; return bless \$x => __PACKAGE__; } + use overload ( '""' => \&toString ); -use overload ( '0+' => sub { $_[0]->toString } ); -use overload ( '+' => sub { int($_[0]) + int($_[1]) } ); -use overload ( '-' => sub { int($_[0]) - int($_[1]) } ); -use overload ( '*' => sub { int($_[0]) * int($_[1]) } ); -use overload ( '/' => sub { int($_[0]) / int($_[1]) } ); -use overload ( '%' => sub { int($_[0]) % int($_[1]) } ); -use overload ( '**' => sub { int($_[0]) ** int($_[1]) } ); -use overload ( 'neg' => sub { -int($_[0]) } ); -use overload ( '==' => sub { int($_[0]->toString) == int($_[1])} ); sub toString { defined($_[1]) ? ${$_[1]} : ${$_[0]} } @@ -106,7 +98,7 @@ sub JSON2perl { s/:/ => /sog; # Do numbers... - s/\b(-?\d+\.?\d*)\b/ JSON::number::new($1) /sog; +# s/\b(-?\d+\.?\d*)\b/ JSON::number::new($1) /sog; # Change javascript stuff to perl... s/null/ undef /sog; -- 2.11.0