diff options
| author | franck cuny <franck@lumberjaph.net> | 2010-07-18 09:00:23 +0200 |
|---|---|---|
| committer | franck cuny <franck@lumberjaph.net> | 2010-07-18 09:00:23 +0200 |
| commit | aebd3a90d2fba77955970e254499277e095736c6 (patch) | |
| tree | e41318678c33c66ad4f07fb43ac7fc7c2b50c5e2 /lib/Net/HTTP/API/Parser/JSON.pm | |
| parent | rename from mx::net::api to net::http::api (diff) | |
| download | net-http-api-aebd3a90d2fba77955970e254499277e095736c6.tar.gz | |
allow nonref for json; clean POD
Diffstat (limited to 'lib/Net/HTTP/API/Parser/JSON.pm')
| -rw-r--r-- | lib/Net/HTTP/API/Parser/JSON.pm | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/Net/HTTP/API/Parser/JSON.pm b/lib/Net/HTTP/API/Parser/JSON.pm index be8b30e..2edc71c 100644 --- a/lib/Net/HTTP/API/Parser/JSON.pm +++ b/lib/Net/HTTP/API/Parser/JSON.pm @@ -6,14 +6,21 @@ use JSON; use Moose; extends 'Net::HTTP::API::Parser'; +has _json_parser => ( + is => 'rw', + isa => 'JSON', + lazy => 1, + default => sub { JSON->new->allow_nonref }, +); + sub encode { my ($self, $content) = @_; - return JSON::encode_json($content); + $self->_json_parser->encode($content); } sub decode { my ($self, $content) = @_; - return JSON::decode_json($content); + $self->_json_parser->decode($content); } 1; |
