Browse Source

json resp

Simon Elliott 12 years ago
parent
commit
5c3ac99e27
1 changed files with 3 additions and 3 deletions
  1. 3 3
      web-simple/app.pl

+ 3 - 3
web-simple/app.pl

@@ -19,11 +19,11 @@ sub dispatch_request {
         my $id = int rand 10000 + 1;
         $sth->execute($id);
         if ( my $row = $sth->fetchrow_hashref ) {
-            push @response,
-              { id => $id, randomNumber => $row->{randomNumber} };
+            push @response, { id => $id, randomNumber => $row->{randomNumber} };
         }
     }
-    [ 200, \@response ];
+    [ 200, [ 'Content-type' => 'application/json; charset=utf-8', ],
+      [ encode_json(\@response)] ];
   }
 }