Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Doc patch #1

Open
wants to merge 1 commit into from

1 participant

@fswitalski

I was a bit confused when it came to sending the json data directly to the body of the response so after I was enlightened I wrote a small doc patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 1, 2010
  1. @fswitalski

    Doc patch

    fswitalski authored
This page is out of date. Refresh to see the latest.
Showing with 20 additions and 0 deletions.
  1. +20 −0 lib/Catalyst/View/JSON.pm
View
20 lib/Catalyst/View/JSON.pm
@@ -141,6 +141,7 @@ Catalyst::View::JSON - JSON view for your data
use base qw( Catalyst::View::JSON );
1;
+ # To access json data through stash variables 'foo' and 'bar'
# configure in lib/MyApp.pm
MyApp->config({
...
@@ -157,6 +158,24 @@ Catalyst::View::JSON - JSON view for your data
$c->forward('View::JSON');
}
+ #######
+
+ # Or return json data in the body
+ # configure in lib/MyApp.pm
+ MyApp->config({
+ ...
+ 'View::JSON' => {
+ expose_stash => 'json_data';
+ }
+ });
+
+ sub hello : Local {
+ my ( $self, $c ) = @_;
+ my @data = qw/One Two Three Four/;
+ $c->stash->{json_data} = \@data;
+ $c->forward('View::JSON');
+ }
+
=head1 DESCRIPTION
Catalyst::View::JSON is a Catalyst View handler that returns stash
@@ -422,6 +441,7 @@ kazeburo
Daisuke Murase
Jun Kuriyama
Tomas Doran
+Frank Switalski
=head1 SEE ALSO
Something went wrong with that request. Please try again.