From 91c1cf1c1b9497ea0ea063cbdb66c6fdcfd6f464 Mon Sep 17 00:00:00 2001 From: miker Date: Mon, 7 Mar 2005 17:00:27 +0000 Subject: [PATCH] fix for JSON regexes git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@188 9efc2488-bf62-4759-914b-345cdb29e865 --- src/perlmods/JSON.pm | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/perlmods/JSON.pm b/src/perlmods/JSON.pm index 97d0ca0..d84ad0b 100644 --- a/src/perlmods/JSON.pm +++ b/src/perlmods/JSON.pm @@ -49,6 +49,7 @@ sub register_class_hint { } JSON->register_class_hint( name => 'JSON::object_unknown', + hint => 'DUNNO', type => 'hash', ); @@ -88,32 +89,32 @@ sub JSON2perl { # Replace with code... s/"(?:(?:\\[\"])|[^\"])*"/ shift(\@strings) /sog; - if (1) { + s/:/ => /sog; + + if (0) { # handle class blessings s/\/\*--\s*S\w*?\s+\S+\s*--\*\// bless(/sog; s/\/\*--\s*E\w*?\s+(\S+)\s*--\*\// => _json_hint_to_class("$1")) /sog; } else { - warn $_."\n\n"; my $string = $_; for my $hint (values %{$_class_map{hints}}) { $string =~ s/\/\*--\s*S\w*?\s+$$hint{hint_re}\s*--\*\// bless(/sog; $string =~ s/\/\*--\s*E\w*?\s+$$hint{hint_re}\s*--\*\// => "$$hint{name}") /sog; - warn $$hint{name}."\n\n"; - warn ' '.$string."\n\n"; } $_ = $string; s/\/\*--\s*\w+\s+\S+\s*--\*\///sog; - warn $_."\n\n"; } - s/\b(-?\d+\.?\d*)/ do { JSON::number::new($1) } /sog; + + s/\b(-?\d+\.?\d*)\b/ JSON::number::new($1) /sog; + # Change javascript stuff to perl... s/null/ undef /sog; - s/:/ => /sog; s/true/ bless( {}, "JSON::bool::true") /sog; s/false/ bless( {}, "JSON::bool::false") /sog; + my $ret; return eval '$ret = '.$_; } -- 2.11.0