r63056 - in /branches/upstream/libjson-perl/current: Changes MANIFEST META.yml README lib/JSON.pm lib/JSON/PP.pm t/e10_bignum.t t/e15_tie_ixhash.t t/xe19_xs_and_suportbypp.t t/xe20_croak_message.t

angelabad-guest at users.alioth.debian.org angelabad-guest at users.alioth.debian.org
Tue Sep 28 19:18:51 UTC 2010


Author: angelabad-guest
Date: Tue Sep 28 19:18:36 2010
New Revision: 63056

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=63056
Log:
[svn-upgrade] new version libjson-perl (2.26)

Added:
    branches/upstream/libjson-perl/current/t/e15_tie_ixhash.t
    branches/upstream/libjson-perl/current/t/xe19_xs_and_suportbypp.t
    branches/upstream/libjson-perl/current/t/xe20_croak_message.t
Modified:
    branches/upstream/libjson-perl/current/Changes
    branches/upstream/libjson-perl/current/MANIFEST
    branches/upstream/libjson-perl/current/META.yml
    branches/upstream/libjson-perl/current/README
    branches/upstream/libjson-perl/current/lib/JSON.pm
    branches/upstream/libjson-perl/current/lib/JSON/PP.pm
    branches/upstream/libjson-perl/current/t/e10_bignum.t

Modified: branches/upstream/libjson-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-perl/current/Changes?rev=63056&op=diff
==============================================================================
--- branches/upstream/libjson-perl/current/Changes (original)
+++ branches/upstream/libjson-perl/current/Changes Tue Sep 28 19:18:36 2010
@@ -15,6 +15,27 @@
 
  !! Since 2.16, PP's relaxed option caused an infinite loop in some condition.
  !! Recommend to update old versions.
+
+2.26  Tue Sep 28 17:41:37 2010
+	[JSON::PP]
+	- cleaned up code and enhanced sort option efficiency in encode.
+
+2.25  Tue Sep 28 16:47:08 2010
+	[JSON]
+	- JSON::Backend::XS::Supportable always executed a needless process
+	    with JSON::XS backend. This made encode/decode a bit slower.
+
+2.24  Mon Sep 27 10:56:24 2010
+	[JSON::PP]
+	- tweaked code.
+	- optimized code in hash object encoding.
+
+2.23  Sun Sep 26 22:08:12 2010
+	[JSON::PP]
+	- modified tied object handling in encode. it made encoding speed faster.
+	    pointed by https://rt.cpan.org/Ticket/Display.html?id=61604
+	- modified t/e10_bignum.t
+            for avoiding a warning in using Math::BigInt dev version
 
 2.22  Wed Aug 25 12:46:13 2010
 	[JSON]

Modified: branches/upstream/libjson-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-perl/current/MANIFEST?rev=63056&op=diff
==============================================================================
--- branches/upstream/libjson-perl/current/MANIFEST (original)
+++ branches/upstream/libjson-perl/current/MANIFEST Tue Sep 28 19:18:36 2010
@@ -50,6 +50,7 @@
 t/e12_upgrade.t
 t/e13_overloaded_eq.t
 t/e14_decode_prefix.t
+t/e15_tie_ixhash.t
 t/x00_load.t
 t/x02_error.t
 t/x12_blessed.t
@@ -63,3 +64,5 @@
 t/xe10_bignum.t
 t/xe11_conv_blessed_univ.t
 t/xe12_boolean.t
+t/xe19_xs_and_suportbypp.t
+t/xe20_croak_message.t

Modified: branches/upstream/libjson-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-perl/current/META.yml?rev=63056&op=diff
==============================================================================
--- branches/upstream/libjson-perl/current/META.yml (original)
+++ branches/upstream/libjson-perl/current/META.yml Tue Sep 28 19:18:36 2010
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               JSON
-version:            2.22
+version:            2.26
 abstract:           JSON (JavaScript Object Notation) encoder/decoder
 author:
     - Makamaka Hannyaharamitu, E<lt>makamaka[at]cpan.orgE<gt>

Modified: branches/upstream/libjson-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-perl/current/README?rev=63056&op=diff
==============================================================================
--- branches/upstream/libjson-perl/current/README (original)
+++ branches/upstream/libjson-perl/current/README Tue Sep 28 19:18:36 2010
@@ -1,4 +1,4 @@
-JSON version 2.21
+JSON version 2.26
 =================
 
 INSTALLATION
@@ -45,7 +45,7 @@
      # recommend to use (en|de)code_json.
  
 VERSION
-        2.22
+        2.26
 
     This version is compatible with JSON::XS 2.27 and later.
 

Modified: branches/upstream/libjson-perl/current/lib/JSON.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-perl/current/lib/JSON.pm?rev=63056&op=diff
==============================================================================
--- branches/upstream/libjson-perl/current/lib/JSON.pm (original)
+++ branches/upstream/libjson-perl/current/lib/JSON.pm Tue Sep 28 19:18:36 2010
@@ -7,7 +7,7 @@
 @JSON::EXPORT = qw(from_json to_json jsonToObj objToJson encode_json decode_json);
 
 BEGIN {
-    $JSON::VERSION = '2.22';
+    $JSON::VERSION = '2.26';
     $JSON::DEBUG   = 0 unless (defined $JSON::DEBUG);
 }
 
@@ -411,6 +411,18 @@
     local $^W;
     no strict qw(refs);
 
+    my $JSON_XS_encode_orignal     = \&JSON::XS::encode;
+    my $JSON_XS_decode_orignal     = \&JSON::XS::decode;
+    my $JSON_XS_incr_parse_orignal = \&JSON::XS::incr_parse;
+
+    *JSON::XS::decode     = \&JSON::Backend::XS::Supportable::_decode;
+    *JSON::XS::encode     = \&JSON::Backend::XS::Supportable::_encode;
+    *JSON::XS::incr_parse = \&JSON::Backend::XS::Supportable::_incr_parse;
+
+    *{JSON::XS::_original_decode}     = $JSON_XS_decode_orignal;
+    *{JSON::XS::_original_encode}     = $JSON_XS_encode_orignal;
+    *{JSON::XS::_original_incr_parse} = $JSON_XS_incr_parse_orignal;
+
     push @JSON::Backend::XS::Supportable::ISA, 'JSON';
 
     my $pkg = 'JSON::Backend::XS::Supportable';
@@ -447,21 +459,6 @@
 #
 
 package JSON::Backend::XS::Supportable;
-
-{
-    my $JSON_XS_encode_orignal = \&JSON::XS::encode;
-    my $JSON_XS_decode_orignal = \&JSON::XS::decode;
-    my $JSON_XS_incr_parse_orignal = \&JSON::XS::incr_parse;
-
-    local $^W;
-    *JSON::XS::decode = \&JSON::Backend::XS::Supportable::_decode;
-    *JSON::XS::encode = \&JSON::Backend::XS::Supportable::_encode;
-    *JSON::XS::incr_parse = \&JSON::Backend::XS::Supportable::_incr_parse;
-
-    *{JSON::XS::_original_decode} = $JSON_XS_decode_orignal;
-    *{JSON::XS::_original_encode} = $JSON_XS_encode_orignal;
-    *{JSON::XS::_original_incr_parse} = $JSON_XS_incr_parse_orignal;
-}
 
 $Carp::Internal{'JSON::Backend::XS::Supportable'} = 1;
 
@@ -614,7 +611,7 @@
  
 =head1 VERSION
 
-    2.22
+    2.26
 
 This version is compatible with JSON::XS B<2.27> and later.
 

Modified: branches/upstream/libjson-perl/current/lib/JSON/PP.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-perl/current/lib/JSON/PP.pm?rev=63056&op=diff
==============================================================================
--- branches/upstream/libjson-perl/current/lib/JSON/PP.pm (original)
+++ branches/upstream/libjson-perl/current/lib/JSON/PP.pm Tue Sep 28 19:18:36 2010
@@ -11,7 +11,7 @@
 use B ();
 #use Devel::Peek;
 
-$JSON::PP::VERSION = '2.27004';
+$JSON::PP::VERSION = '2.27007';
 
 @JSON::PP::EXPORT = qw(encode_json decode_json from_json to_json);
 
@@ -40,6 +40,8 @@
 
 use constant P_ALLOW_UNKNOWN        => 18;
 
+use constant OLD_PERL => $] < 5.008 ? 1 : 0;
+
 BEGIN {
     my @xs_compati_bit_properties = qw(
             latin1 ascii utf8 indent canonical space_before space_after allow_nonref shrink
@@ -356,8 +358,7 @@
 
     sub hash_to_json {
         my ($self, $obj) = @_;
-        my ($k,$v);
-        my %res;
+        my @res;
 
         encode_error("json text or perl structure exceeds maximum nesting level (max_depth set too low?)")
                                          if (++$depth > $max_depth);
@@ -365,34 +366,17 @@
         my ($pre, $post) = $indent ? $self->_up_indent() : ('', '');
         my $del = ($space_before ? ' ' : '') . ':' . ($space_after ? ' ' : '');
 
-        if ( my $tie_class = tied %$obj ) {
-            if ( $tie_class->can('TIEHASH') ) {
-                $tie_class =~ s/=.+$//;
-                tie %res, $tie_class;
-            }
-        }
-
-        # In the old Perl verions, tied hashes in bool context didn't work.
-        # So, we can't use such a way (%res ? a : b)
-        my $has;
-
-        for my $k (keys %$obj) {
-            my $v = $obj->{$k};
-            $res{$k} = $self->object_to_json($v) || $self->value_to_json($v);
-            $has = 1 unless ( $has );
+        for my $k ( _sort( $obj ) ) {
+            if ( OLD_PERL ) { utf8::decode($k) } # key for Perl 5.6 / be optimized
+            push @res, string_to_json( $self, $k )
+                          .  $del
+                          . ( $self->object_to_json( $obj->{$k} ) || $self->value_to_json( $obj->{$k} ) );
         }
 
         --$depth;
         $self->_down_indent() if ($indent);
 
-        return '{' . ( $has ? $pre : '' )                                                   # indent
-                   . ( $has ? join(",$pre", map { utf8::decode($_) if ($] < 5.008);         # key for Perl 5.6
-                                                string_to_json($self, $_) . $del . $res{$_} # key : value
-                                            } _sort( $self, \%res )
-                             ) . $post                                                      # indent
-                           : ''
-                     )
-             . '}';
+        return   '{' . ( @res ? $pre : '' ) . ( @res ? join( ",$pre", @res ) . $post : '' )  . '}';
     }
 
 
@@ -404,13 +388,6 @@
                                          if (++$depth > $max_depth);
 
         my ($pre, $post) = $indent ? $self->_up_indent() : ('', '');
-
-        if (my $tie_class = tied @$obj) {
-            if ( $tie_class->can('TIEARRAY') ) {
-                $tie_class =~ s/=.+$//;
-                tie @res, $tie_class;
-            }
-        }
 
         for my $v (@$obj){
             push @res, $self->object_to_json($v) || $self->value_to_json($v);
@@ -535,8 +512,7 @@
 
 
     sub _sort {
-        my ($self, $res) = @_;
-        defined $keysort ? (sort $keysort (keys %$res)) : keys %$res;
+        defined $keysort ? (sort $keysort (keys %{$_[0]})) : keys %{$_[0]};
     }
 
 

Modified: branches/upstream/libjson-perl/current/t/e10_bignum.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-perl/current/t/e10_bignum.t?rev=63056&op=diff
==============================================================================
--- branches/upstream/libjson-perl/current/t/e10_bignum.t (original)
+++ branches/upstream/libjson-perl/current/t/e10_bignum.t Tue Sep 28 19:18:36 2010
@@ -12,8 +12,11 @@
 SKIP: {
     skip "Can't load Math::BigInt.", 6 if ($@);
 
-my $fix =  !Math::BigInt->VERSION       ? '+'
-          : Math::BigInt->VERSION < 1.6 ? '+'
+    my $v = Math::BigInt->VERSION;
+    $v =~ s/_.+$// if $v;
+
+my $fix =  !$v       ? '+'
+          : $v < 1.6 ? '+'
           : '';
 
 

Added: branches/upstream/libjson-perl/current/t/e15_tie_ixhash.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-perl/current/t/e15_tie_ixhash.t?rev=63056&op=file
==============================================================================
--- branches/upstream/libjson-perl/current/t/e15_tie_ixhash.t (added)
+++ branches/upstream/libjson-perl/current/t/e15_tie_ixhash.t Tue Sep 28 19:18:36 2010
@@ -1,0 +1,44 @@
+
+use strict;
+use Test::More;
+BEGIN { plan tests => 2 };
+
+BEGIN { $ENV{PERL_JSON_BACKEND} = 0; }
+
+use JSON;
+
+# from https://rt.cpan.org/Ticket/Display.html?id=25162
+
+SKIP: {
+    eval {require Tie::IxHash};
+    skip "Can't load Tie::IxHash.", 2 if ($@);
+
+    my %columns;
+    tie %columns, 'Tie::IxHash';
+
+    %columns = (
+    id => 'int',
+    1 => 'a',
+    2 => 'b',
+    3 => 'c',
+    4 => 'd',
+    5 => 'e',
+    );
+
+    my $js = to_json(\%columns);
+    is( $js, q/{"id":"int","1":"a","2":"b","3":"c","4":"d","5":"e"}/ );
+
+    $js = to_json(\%columns, {pretty => 1});
+    is( $js, <<'STR' );
+{
+   "id" : "int",
+   "1" : "a",
+   "2" : "b",
+   "3" : "c",
+   "4" : "d",
+   "5" : "e"
+}
+STR
+
+}
+

Added: branches/upstream/libjson-perl/current/t/xe19_xs_and_suportbypp.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-perl/current/t/xe19_xs_and_suportbypp.t?rev=63056&op=file
==============================================================================
--- branches/upstream/libjson-perl/current/t/xe19_xs_and_suportbypp.t (added)
+++ branches/upstream/libjson-perl/current/t/xe19_xs_and_suportbypp.t Tue Sep 28 19:18:36 2010
@@ -1,0 +1,34 @@
+#! perl
+
+# https://rt.cpan.org/Public/Bug/Display.html?id=52847
+
+use strict;
+use Test::More;
+
+BEGIN { plan tests => 2 };
+BEGIN { $ENV{PERL_JSON_BACKEND} = 1; }
+
+use JSON -support_by_pp;
+
+SKIP: {
+    skip "can't use JSON::XS.", 2, unless( JSON->backend->is_xs );
+
+    my $json = JSON->new->allow_barekey;
+
+    for (1..2) {
+        is_deeply( test($json, q!{foo:"foo"}!   ), {foo=>'foo'} );
+        JSON->new->allow_singlequote(0);
+    }
+}
+
+
+sub test {
+    my ($coder, $str) = @_;
+    my $rv;
+    return $rv if eval { $rv = $coder->decode($str); 1 };
+    chomp( my $e = $@ );
+    return "died with \"$e\"";
+};
+
+
+

Added: branches/upstream/libjson-perl/current/t/xe20_croak_message.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-perl/current/t/xe20_croak_message.t?rev=63056&op=file
==============================================================================
--- branches/upstream/libjson-perl/current/t/xe20_croak_message.t (added)
+++ branches/upstream/libjson-perl/current/t/xe20_croak_message.t Tue Sep 28 19:18:36 2010
@@ -1,0 +1,22 @@
+#! perl
+
+# https://rt.cpan.org/Public/Bug/Display.html?id=61708
+
+use strict;
+use Test::More;
+
+BEGIN { plan tests => 1 };
+BEGIN { $ENV{PERL_JSON_BACKEND} = 1; }
+
+use JSON; # currently it can't pass with -support_by_pp;
+
+
+SKIP: {
+    skip "can't use JSON::XS.", 1, unless( JSON->backend->is_xs );
+
+    my $json = JSON->new;
+
+    eval q{ $json->encode( undef ) };
+    like( $@, qr/line 1\./ );
+}
+




More information about the Pkg-perl-cvs-commits mailing list