Merge branch 'runarbu-master'
[catagits/Catalyst-Action-REST.git] / lib / Catalyst / Action / Serialize / JSON.pm
index a9db571..e618248 100644 (file)
@@ -4,10 +4,7 @@ use Moose;
 use namespace::autoclean;
 
 extends 'Catalyst::Action';
-use JSON ();
-
-our $VERSION = '1.00';
-$VERSION = eval $VERSION;
+use JSON::MaybeXS qw(JSON);
 
 has encoder => (
    is => 'ro',
@@ -23,6 +20,12 @@ sub execute {
     my $self = shift;
     my ( $controller, $c ) = @_;
 
+    if (my $options = $controller->{json_options_encode}) {
+        foreach my $opt (keys %$options) {
+            $self->encoder->$opt( $options->{$opt} );
+        }
+    }
+
     my $stash_key = (
             $controller->{'serialize'} ?
                 $controller->{'serialize'}->{'stash_key'} :