lls the whole thing you get back from a JMAP server a "response"
#pod if it's an HTTP 200. Every JSON Array (of three entries -- go read the spec if
#pod you need to!) is called a L<Sentence|JMAP::Te
L<JSON::Typist>, so you may want to strip their type data before using normal
#pod Perl code on them. You can do that with:
#pod
#pod my $struct = $response->as_triples; # gets the complete JSON d
ata
#pod $jtest->strip_json_types( $struct ); # strips all the JSON::Typist types
#pod
#pod Or more simply:
#pod
#pod my $struct = $response->as_stripped_triples;
#pod
#pod There is also L<JMAP::T
$self->_strip_json_types( $self->create_errors )
);
}
if (keys %{ $self->update_errors }) {
push @errors, "notUpdated: " . Data::Dumper::Dumper(
$self->_strip_json_types( $self->
stroy_errors }) {
push @errors, "notDestroyed: " . Data::Dumper::Dumper(
$self->_strip_json_types( $self->destroy_errors )
);
}
return $self unless @errors;
$self->sentence_brok
dumper {
state $default = do {
require JSON::MaybeXS;
state $json = JSON::MaybeXS->new->utf8->convert_blessed->pretty->canonical;
sub { $json->encode($_[0]); }
};
return $default;
}
sentence_broker => (is => 'ro', required => 1);
sub _strip_json_types {
my ($self, $whatever) = @_;
$self->sentence_broker->strip_json_types($whatever);
}
#pod =method as_triple
#pod
#pod =meth
od as_stripped_triple
#pod
#pod C<as_triple> returns the underlying JSON data of the sentence, which may
#pod include objects used to convey type information for booleans, strings, and
#pod numbers.
#
$_[0]->arguments, $_[0]->client_id ] }
sub as_stripped_triple {
$_[0]->sentence_broker->strip_json_types($_[0]->as_triple);
}
#pod =method as_pair
#pod
#pod =method as_stripped_pair
#pod
#pod C<a
calling
#pod C<as_triple> on each sentence in the paragraph. C<as_stripped_triples> removes
#pod JSON types.
#pod
#pod =cut
sub as_triples {
[ map {; $_->as_triple } $_[0]->sentences ]
}
sub as_s
result of calling C<as_pair>
#pod on each sentence in the paragraph. C<as_stripped_pairs> removes JSON types.
#pod
#pod =cut
sub as_pairs {
[ map {; $_->as_pair } $_[0]->sentences ]
}
sub as_strip
les> removes
JSON types.
=head2 as_pairs
C<as_pairs> returns an arrayref containing the result of calling C<as_pair>
on each sentence in the paragraph. C<as_stripped_pairs> removes JSON types.
=hea
_default_headers => (
is => 'ro',
default => sub {
{
'Content-Type' => 'application/json',
}
},
);
sub get_default_header {
my ($self, $name) = @_;
return scalar $self->_defa
for my $m (qw(
client_ids_for_items
sentence_for_item
paragraph_for_items
strip_json_types
abort
)) {
my $sub = sub {
my $self = shift;
$self->sentence_broker-
he data returned by the
#pod JMAP server. With C<as_triples>, some of the JSON data may be in objects
#pod provided by L<JSON::Typist>. If you'd prefer raw data, use the
#pod C<as_stripped_triples> f
le }
$self->items
];
}
sub as_stripped_triples {
my ($self) = @_;
return $self->strip_json_types($self->as_triples);
}
#pod =method as_pairs
#pod
#pod =method as_stripped_pairs
#pod
#pod
nt_ids_for_items';
requires 'sentence_for_item';
requires 'paragraph_for_items';
requires 'strip_json_types';
requires 'abort';
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
JMAP::Tester::Role::
serAgent->new;
$lwp->cookie_jar({});
$lwp->default_header('Content-Type' => 'application/json');
if ($ENV{IGNORE_INVALID_CERT}) {
$lwp->ssl_opts(SSL_verify_mode => 0, verify_hostna
ring,
(@diagnostics ? (diagnostics => \@diagnostics) : ()),
});
}
sub strip_json_types {
state $typist = JSON::Typist->new;
$typist->strip_types($_[1]);
}
no Moo;
1;
__END__
=pod
=encod