Bio::Phylo::Unparsers::Json - Serializer used by Bio::Phylo::IO, no serviceable


Bio-Phylo documentation Contained in the Bio-Phylo distribution.

Index


Code Index:

NAME

Top

Bio::Phylo::Unparsers::Json - Serializer used by Bio::Phylo::IO, no serviceable parts inside

DESCRIPTION

Top

This module turns the supplied object into a JSON string.

SEE ALSO

Top

Bio::Phylo::IO

The json unparser is called by the Bio::Phylo::IO object. Look there to learn how to unparse objects.

Bio::Phylo::Manual

Also see the manual: Bio::Phylo::Manual and http://rutgervos.blogspot.com.

http://www.json.org

To learn more about the JavaScript Object Notation (JSON) format, visit http://www.json.org.

CITATION

Top

If you use Bio::Phylo in published research, please cite it:

Rutger A Vos, Jason Caravas, Klaas Hartmann, Mark A Jensen and Chase Miller, 2011. Bio::Phylo - phyloinformatic analysis using Perl. BMC Bioinformatics 12:63. http://dx.doi.org/10.1186/1471-2105-12-63

REVISION

Top

 $Id: Mrp.pm 1660 2011-04-02 18:29:40Z rvos $


Bio-Phylo documentation Contained in the Bio-Phylo distribution.
# $Id: Mrp.pm 1660 2011-04-02 18:29:40Z rvos $
package Bio::Phylo::Unparsers::Json;
use strict;
use base 'Bio::Phylo::Unparsers::Abstract';
use Bio::Phylo::Util::CONSTANT qw'/looks_like/';
use Bio::Phylo::Util::Exceptions 'throw';
use Bio::Phylo::Util::Dependency qw'XML::XML2JSON';

sub _to_string {
    my $self = shift;
    my $obj  = $self->{'PHYLO'};
    if ( looks_like_implementor $obj, 'to_json' ) {
        return $obj->to_json;
    }
    else {
        throw 'ObjectMismatch' => "Can't make JSON string out of $obj";
    }
}

# podinherit_insert_token

1;