VERSION = '0.102740';
}
# ABSTRACT: Subroutines for internal use
use strict;
use warnings;
use JSON;
use LWP::UserAgent;
use Scalar::Util qw{ blessed };
use URI::Escape;
# transform hash keys and
e ) = @_;
if ( $type ne 'jsontext' ) {
confess q{the only valid value is 'jsontext'};
}
},
);
has [
qw{
key
jsonp
}
] => (
is => 'r
is C<jsontext>. Responds with mime-type text/json, if set.
=head2 C<key>
Accepts a key and validates this request to a specific application.
=head2 C<jsonp>
If set, the response returns JSON with
Padding instead of standard JSON.
=head1 AUTHOR
Alan Haggai Alavi <alanhaggai@alanhaggai.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Alan Haggai Alavi.
This is free
ABSTRACT: Request methods for answers
use Moose;
use Moose::Util::TypeConstraints;
use JSON qw{ decode_json };
with 'Net::StackExchange::Role::Request';
has 'id' => (
is => 'ro',
is
$self = shift;
my $json = Net::StackExchange::Core::_execute($self);
my $se = $self->_NSE();
my $json_decoded = decode_json($json);
my $response = Net::Stac
=> $se,
'_json_decoded' => $json_decoded,
'json' => $json,
'total' => $json_decoded->{'total' },
'page' => $json_decoded->{'page' },
s
use Moose;
use Moose::Util::TypeConstraints;
with 'Net::StackExchange::Role::Response';
has 'json' => (
is => 'ro',
isa => 'Str',
required => 1,
);
has 'answers' => (
et::StackExchange::Answers]',
writer => 'set_answers',
reader => 'get_answers',
);
has '_json_decoded' => (
is => 'ro',
isa => 'HashRef',
required => 1,
trigger =>
_object {
my $self = shift;
my $json = $self->json();
my $json_decoded = $self->_json_decoded();
my @answers;
for my $answer_ref ( @{ $json_decoded->{'answers'} } ) {
my
ts;
use JSON;
subtype 'List::id'
=> as 'Str'
=> where { $_ =~ /^(?:\d;?)+$/ };
subtype 'JSON::XS::Boolean'
=> as 'JSON::XS::Boolean';
subtype 'JSON::PP::Boolean'
=> as 'JSON::PP::Bo
'
=> from 'JSON::XS::Boolean'
=> via {
if ( JSON::is_bool($_) && $_ == JSON::true ) {
return 'true';
}
return 'false';
}
=> from 'JSON::PP::Boolean'
=> via {
if ( JSON::is_bool($_) && $_ == JSON::true ) {
return 'true';
}
return 'false';
}
=> from 'Int'
=> via {
if ($_) {
ret