From: miker Date: Tue, 8 Mar 2005 05:34:39 +0000 (+0000) Subject: YAY! Unicode works now! X-Git-Tag: osrf_rel_2_0_1~1670 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a2075b94e7e0a28a48fbd4aa97ade82c763d8754;p=OpenSRF.git YAY! Unicode works now! git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@202 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/src/perlmods/JSON.pm b/src/perlmods/JSON.pm index db0d59e..6027c92 100644 --- a/src/perlmods/JSON.pm +++ b/src/perlmods/JSON.pm @@ -81,28 +81,24 @@ sub JSON2perl { my $class = shift; local $_ = shift; + # remove C++ comments + s/\/\/.+$//sgmo; + + # Convert JSON Unicode... + s/\\u(\d{4})/chr(hex($1))/esog; + # Grab strings... my @strings = /"((?:(?:\\[\"])|[^\"])*)"/sog; + # Replace with code... s/"(?:(?:\\[\"])|[^\"])*"/ shift(\@strings) /sog; + # Perlify hash notation s/:/ => /sog; - if (1) { - # 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 { - #why don't I work?!?! - #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; - #} - #$_ = $string; - #s/\/\*--\s*\w+\s+\S+\s*--\*\///sog; - } - + # 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; s/\b(-?\d+\.?\d*)\b/ JSON::number::new($1) /sog; @@ -112,7 +108,6 @@ sub JSON2perl { s/true/ bless( {}, "JSON::bool::true") /sog; s/false/ bless( {}, "JSON::bool::false") /sog; - my $ret; return eval '$ret = '.$_; } @@ -124,7 +119,6 @@ sub old_JSON2perl { return undef; } - #$json =~ s/\/\/.+$//gmo; # remove C++ comments $json =~ s/(?