Phylo/Unparsers/Json.pm untested

filter: Statementstmt 0.0% 0 / 23 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 33 CC 2 SCAR 11.0
CC
2
Cov
0%
_to_string
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.0
1 package Bio::Phylo::Unparsers::Json;
2 use strict;
3 use warnings;
4 use base 'Bio::Phylo::Unparsers::Abstract';
5 use Bio::Phylo::Util::CONSTANT qw'/looks_like/';
6 use Bio::Phylo::Util::Exceptions 'throw';
7 use Bio::Phylo::Util::Dependency qw'XML::XML2JSON';
8  
9 =head1 NAME
10  
11 Bio::Phylo::Unparsers::Json - Serializer used by Bio::Phylo::IO, no serviceable
12 parts inside
13  
14 =head1 DESCRIPTION
15  
16 This module turns the supplied object into a JSON string.
17  
18 =begin comment
19  
20 Type : Wrapper
21 Title : _to_string
22 Usage : my $json_string = $obj->_to_string;
23 Function: Stringifies a Bio::Phylo object into a JSON string
24 Alias :
25 Returns : SCALAR
26 Args : Bio::Phylo::* object
27  
28 =end comment
29  
30 =cut
31  
32 sub _to_string {
33 my $self = shift;
34 my $obj = $self->{'PHYLO'};
35 if ( looks_like_implementor $obj, 'to_json' ) {
36 return $obj->to_json;
37 }
38 else {
39 throw 'ObjectMismatch' => "Can't make JSON string out of $obj";
40 }
41 }
42  
43 # podinherit_insert_token
44  
45 =head1 SEE ALSO
46  
47 There is a mailing list at L<https://groups.google.com/forum/#!forum/bio-phylo>
48 for any user or developer questions and discussions.
49  
50 =over
51  
52 =item L<Bio::Phylo::IO>
53  
54 The json unparser is called by the L<Bio::Phylo::IO> object.
55 Look there to learn how to unparse objects.
56  
57 =item L<Bio::Phylo::Manual>
58  
59 Also see the manual: L<Bio::Phylo::Manual> and L<http://rutgervos.blogspot.com>.
60  
61 =item L<http://www.json.org>
62  
63 To learn more about the JavaScript Object Notation (JSON) format, visit
64 L<http://www.json.org>.
65  
66 =back
67  
68 =head1 CITATION
69  
70 If you use Bio::Phylo in published research, please cite it:
71  
72 B<Rutger A Vos>, B<Jason Caravas>, B<Klaas Hartmann>, B<Mark A Jensen>
73 and B<Chase Miller>, 2011. Bio::Phylo - phyloinformatic analysis using Perl.
74 I<BMC Bioinformatics> B<12>:63.
75 L<http://dx.doi.org/10.1186/1471-2105-12-63>
76  
77 =cut
78  
79 1;