Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Allow JSON object to be set #15

Merged
merged 2 commits into from

2 participants

@abh
abh commented

No description provided.

@miyagawa
Owner

Thanks - though i'm not really sure if the change is compatible since JSON::encode_json for instance is not compatible to JSON->new->encode(). Rather I thought it's something like JSON->new->utf8->encode(). Ditto for the decode_utf8.

Good catch! I fixed that just now in the next commit.

@abh abh Default the JSON object to be utf8 enabled
(to work the same as JSON::encode_json() from before; thanks Miyagawa!)
e8b1997
@abh
abh commented

Ping!

@miyagawa miyagawa merged commit 66905d3 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 30, 2010
  1. @abh
  2. @abh

    Default the JSON object to be utf8 enabled

    abh authored
    (to work the same as JSON::encode_json() from before; thanks Miyagawa!)
This page is out of date. Refresh to see the latest.
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($_), @_;
Something went wrong with that request. Please try again.