Committer: ailyin
LJSUP-9908 (LJ SHOP 2011 update)A trunk/cgi-bin/LJ/Response/JSON.pm U trunk/cgi-bin/LJ/Response.pm
Added: trunk/cgi-bin/LJ/Response/JSON.pm =================================================================== --- trunk/cgi-bin/LJ/Response/JSON.pm (rev 0) +++ trunk/cgi-bin/LJ/Response/JSON.pm 2011-10-26 12:43:45 UTC (rev 11119) @@ -0,0 +1,21 @@ +package LJ::Response::JSON; +use strict; +use warnings; + +use LJ::JSON; + +use base qw( LJ::Response ); +__PACKAGE__->mk_accessors( qw( data ) ); + +sub output { + my ($self) = @_; + + my $output = LJ::JSON->to_json( $self->data ); + + LJ::Request->content_type('application/json; charset=utf-8'); + LJ::Request->send_cookies; + LJ::Request->send_http_header(); + LJ::Request->print($final_output); +} + +1; Modified: trunk/cgi-bin/LJ/Response.pm =================================================================== --- trunk/cgi-bin/LJ/Response.pm 2011-10-26 08:17:42 UTC (rev 11118) +++ trunk/cgi-bin/LJ/Response.pm 2011-10-26 12:43:45 UTC (rev 11119) @@ -7,6 +7,7 @@ use LJ::Request; use LJ::Response::Error; +use LJ::Response::JSON; use LJ::Response::Redirect; use LJ::Response::Template;