<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Dec 3, 2007, at 4:38 PM, Ian Docherty wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"> <div bgcolor="#ffffff" text="#000000">Tatsuhiko Miyagawa wrote: <blockquote cite="mid:693254b90712031159g37160be4gb71ef9787becb973@mail.gmail.com" type="cite"> <pre wrap="">On 12/3/07, Ian Docherty <a class="moz-txt-link-rfc2396E" href="mailto:catalyst@iandocherty.com"><catalyst@iandocherty.com></a> wrote:<br></pre> <blockquote type="cite"> <pre wrap="">On looking at the code for C::V::JSON it creates a new JSON::Any object
but does not pass on any parameters (probably because there is no
standard parameter mappings for the different JSON modules).
I am at a loss as to how to do this without writing my own C::V::JSON<br></pre> </blockquote> <pre wrap=""><!---->Can you s/writing my own/submtiting a patch for/? </pre> </blockquote> <br></div></blockquote><blockquote type="cite">A quick patch that works for me, please see if it is compatible with the way you want the code to work. (Apologies if the patch is not correct, I am not too familiar with creating patch files).<br><br></blockquote>Although I like the idea, this patch will blow up on anyone who is already using the package, as you don't provide any defaults for the new accessor. You probably want to replace:</div><div><br class="webkit-block-placeholder"></div><div>my $json = JSON::Any->new(%{$self->params}); # create the copy of JSON handler</div><div><br class="webkit-block-placeholder"></div><div>with</div><div><br class="webkit-block-placeholder"></div><div>my $json = JSON::Any->new( %{ $self->params || {} } ); # create the copy of JSON handler</div><div><br><blockquote type="cite"><div bgcolor="#ffffff" text="#000000"> @@ -9,7 +9,7 @@<br> use Catalyst::Exception;<br> require JSON::Any;<br> <br> -__PACKAGE__->mk_accessors(qw( allow_callback callback_param expose_stash encoding json_dumper no_x_json_header ));<br> +__PACKAGE__->mk_accessors(qw( params allow_callback callback_param expose_stash encoding json_dumper no_x_json_header ));<br> <br> sub new {<br> my($class, $c, $arguments) = @_;<br> @@ -29,7 +29,7 @@<br> <br> eval {<br> JSON::Any->import($driver);<br> - my $json = JSON::Any->new; # create the copy of JSON handler<br> + my $json = JSON::Any->new(%{$self->params}); # create the copy of JSON handler<br> $self->json_dumper(sub { $json->objToJson($_[0]) });<br> };<br> <br> @@ -134,6 +134,7 @@<br> MyApp->config({<br> ...<br> 'View::JSON' => {<br> + params => {pretty => 1, indent => 2}, # pass params to the JSON module<br> allow_callback => 1, # defaults to 0<br> callback_param => 'cb', # defaults to 'callback'<br> expose_stash => [ qw(foo bar) ], # defaults to everything<br> <br> </div> _______________________________________________<br>List: <a href="mailto:Catalyst@lists.scsys.co.uk">Catalyst@lists.scsys.co.uk</a><br>Listinfo: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst</a><br>Searchable archive: <a href="http://www.mail-archive.com/catalyst@lists.rawmode.org/">http://www.mail-archive.com/catalyst@lists.rawmode.org/</a><br>Dev site: <a href="http://dev.catalyst.perl.org/">http://dev.catalyst.perl.org/</a><br></blockquote></div><br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div>-- </div><div>Jason Kohles, RHCA RHCDS RHCE</div><div>email@jasonkohles.com - <a href="http://www.jasonkohles.com/">http://www.jasonkohles.com/</a></div><div>"A witty saying proves nothing." -- Voltaire</div></span></span></div><br class="Apple-interchange-newline"></span> </div><br></body></html>