line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Message::Passing::Filter::Decoder::JSON; |
2
|
4
|
|
|
4
|
|
3071
|
use Moo; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
23
|
|
3
|
4
|
|
|
4
|
|
1693
|
use JSON::MaybeXS qw( decode_json ); |
|
4
|
|
|
|
|
4659
|
|
|
4
|
|
|
|
|
291
|
|
4
|
4
|
|
|
4
|
|
26
|
use Try::Tiny; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
218
|
|
5
|
4
|
|
|
4
|
|
1597
|
use Message::Passing::Exception::Decoding; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
149
|
|
6
|
4
|
|
|
4
|
|
26
|
use namespace::clean -except => 'meta'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
19
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
with qw/ |
9
|
|
|
|
|
|
|
Message::Passing::Role::Filter |
10
|
|
|
|
|
|
|
Message::Passing::Role::HasErrorChain |
11
|
|
|
|
|
|
|
/; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub filter { |
14
|
4
|
|
|
4
|
1
|
13
|
my ($self, $message) = @_; |
15
|
|
|
|
|
|
|
try { |
16
|
4
|
100
|
|
4
|
|
200
|
ref($message) ? $message : decode_json( $message ) |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
catch { |
19
|
1
|
|
|
1
|
|
66
|
$self->error->consume(Message::Passing::Exception::Decoding->new( |
20
|
|
|
|
|
|
|
exception => $_, |
21
|
|
|
|
|
|
|
packed_data => $message, |
22
|
|
|
|
|
|
|
)); |
23
|
1
|
|
|
|
|
26
|
return; # Explicit return undef |
24
|
4
|
|
|
|
|
31
|
}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 NAME |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Message::Passing::Role::Filter::Decoder::JSON |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Decodes string messages from JSON into data structures. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 METHODS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 filter |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
JSON decodes a message supplied as a parameter. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SEE ALSO |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=over |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item L<Message::Passing> |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item L<Message::Passing::Manual::Concepts> |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=back |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 SPONSORSHIP |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This module exists due to the wonderful people at Suretec Systems Ltd. |
58
|
|
|
|
|
|
|
<http://www.suretecsystems.com/> who sponsored its development for its |
59
|
|
|
|
|
|
|
VoIP division called SureVoIP <http://www.surevoip.co.uk/> for use with |
60
|
|
|
|
|
|
|
the SureVoIP API - |
61
|
|
|
|
|
|
|
<http://www.surevoip.co.uk/support/wiki/api_documentation> |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 AUTHOR, COPYRIGHT AND LICENSE |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
See L<Message::Passing>. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
|