Add new serializer for JSON::XS
Tomas Doran (t0m) [Mon, 17 Aug 2009 12:47:28 +0000 (13:47 +0100)]
Changes
lib/Catalyst/Action/Serialize/JSON.pm
lib/Catalyst/Action/Serialize/JSON/XS.pm [new file with mode: 0644]

diff --git a/Changes b/Changes
index 0706c73..41beea1 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,7 @@
+Mon Aug 17 13:46:41 BST 2009 (t0m) - Release 0.75
+
+  Added a serializer for JSON::XS
+
   Made test independent of YAML::Syck bugs (dandv)
 
 Wed Jul 22 23:49:16 BST 2009 (t0m) - Release 0.74
index 561b49b..a681bcf 100644 (file)
@@ -24,7 +24,7 @@ sub execute {
         ) || 'rest';
     my $output;
     eval {
-        $output = encode_json( $c->stash->{$stash_key} );
+        $output = $self->encode( $c->stash->{$stash_key} );
     };
     if ($@) {
         return $@;
@@ -33,4 +33,9 @@ sub execute {
     return 1;
 }
 
+sub encode {
+    my $self = shift;
+    encode_json( @_ );
+}
+
 1;
diff --git a/lib/Catalyst/Action/Serialize/JSON/XS.pm b/lib/Catalyst/Action/Serialize/JSON/XS.pm
new file mode 100644 (file)
index 0000000..6413db9
--- /dev/null
@@ -0,0 +1,14 @@
+package Catalyst::Action::Serialize::JSON::XS;
+
+use strict;
+use warnings;
+
+use base 'Catalyst::Action::Serialize::JSON';
+use JSON::XS qw(encode_json);
+
+sub encode {
+    my $self = shift;
+    encode_json( @_ );
+}
+
+1;