User:AnomieBOT/source/AnomieBOT/API/Toolforge/Response.pm

package AnomieBOT::API::Toolforge::Reponse;

use utf8;
use strict;

use parent 'HTTP::Response';

use JSON;

=pod

=head1 NAME

AnomieBOT::API::Toolforge::Reponse - HTTP::Response subclass

=head1 SYNOPSIS

 my $json = $response->json_content()

=head1 DESCRIPTION

C<AnomieBOT::API::Toolforge::Reponse> is a subclass of L<HTTP::Response|HTTP::Response(3pm)>
that adds a C<json_content> method which JSON-decodes the C<decoded_content>.

=cut

sub json_content {
    my ($self) = @_;

    return JSON->new->decode( $self->decoded_content );
}

1;