Skip to content
Browse files

Merge pull request #15 from abh/e8b1997b71dc9cca139c365ea1460bde34eef8f1

Allow JSON object to be set
  • Loading branch information...
2 parents 6bebf2a + e8b1997 commit 66905d358049b2e0e474a0ec6e5209ca112ceec9 @miyagawa committed May 10, 2011
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/Tatsumaki/Handler.pm
View
5 lib/Tatsumaki/Handler.pm
@@ -17,6 +17,7 @@ has args => (is => 'rw', isa => 'ArrayRef');
has writer => (is => 'rw');
has mxhr => (is => 'rw', isa => 'Bool');
has mxhr_boundary => (is => 'rw', isa => 'Str', lazy => 1, lazy_build => 1);
+has json => (is => 'rw', isa => 'JSON', lazy => 1, default => sub { JSON->new->utf8 });
has _write_buffer => (is => 'rw', isa => 'ArrayRef', lazy => 1, default => sub { [] });
@@ -165,11 +166,11 @@ sub get_chunk {
my $self = shift;
if (ref $_[0]) {
if ($self->mxhr) {
- my $json = JSON::encode_json($_[0]);
+ my $json = $self->json->encode($_[0]);
return "Content-Type: application/json\n\n$json\n--" . $self->mxhr_boundary. "\n";
} else {
$self->response->content_type('application/json');
- return JSON::encode_json($_[0]);
+ return $self->json->encode($_[0]);
}
} else {
join '', map Encode::encode_utf8($_), @_;

0 comments on commit 66905d3

Please sign in to comment.
Something went wrong with that request. Please try again.