Tests which I believe show that JSON encoding is handled correctly. I.E. You pass...
[catagits/Catalyst-Action-REST.git] / t / lib / Test / Serialize / Controller / REST.pm
index abeb01f..dad5483 100644 (file)
@@ -12,6 +12,7 @@ __PACKAGE__->config(
         'text/html'          => 'YAML::HTML',
         'text/xml'           => 'XML::Simple',
         'text/x-yaml'        => 'YAML',
+        'application/json'   => 'JSON',
         'text/x-json'        => 'JSON',
         'text/x-data-dumper' => [ 'Data::Serializer', 'Data::Dumper' ],
         'text/x-data-denter' => [ 'Data::Serializer', 'Data::Denter' ],
@@ -30,11 +31,13 @@ __PACKAGE__->config(
 
 sub monkey_put : Local : ActionClass('Deserialize') {
     my ( $self, $c ) = @_;
-       if ( ref($c->req->data) eq "HASH" ) {
-               $c->res->output( $c->req->data->{'sushi'} );
-       } else {
-               $c->res->output(1);
-       }
+    if ( ref($c->req->data) eq "HASH" ) {
+        my $out = $c->req->data->{'sushi'} . $c->req->data->{'chicken'}||'';
+        utf8::encode($out);
+        $c->res->output( $out );
+    } else {
+        $c->res->output(1);
+    }
 }
 
 sub monkey_get : Local : ActionClass('Serialize') {
@@ -43,4 +46,3 @@ sub monkey_get : Local : ActionClass('Serialize') {
 }
 
 1;
-