phylo>
for any user or developer questions and discussions.
=over
=item L<Bio::Phylo::IO>
The json unparser is called by the L<Bio::Phylo::IO> object.
Look there to learn how to unparse objects.
tp://rutgervos.blogspot.com>.
=item L<http://www.json.org>
To learn more about the JavaScript Object Notation (JSON) format, visit
L<http://www.json.org>.
=back
=head1 CITATION
If you use Bio::Ph
of the provided project
=begin comment
Type : Wrapper
Title : _to_string
Usage : my $json_string = $obj->_to_string;
Function: Stringifies a Bio::Phylo object into an HTML string
Alias
#!/usr/bin/perl
use strict;
use warnings;
use Net::AMQP::RabbitMQ;
use Getopt::Long;
use JSON;
use Time::HiRes qw(sleep);
our $VERSION = '0.1';
my $hostname = 'localhost';
my $user = 'guest';
my $pa
connect($hostname, { user => $user, password => $password });
$mq->channel_open($channel);
my $json = JSON->new;
my $i = 0;
my $uuids = {};
while (1) {
my $msg = $mq->get($channel, $queue, {no_ac
f (!$msg) {
last;
}
printf "Got message: %s\n", $msg->{body};
my $uuid = from_json($msg->{body})->{uuid};
if ($uuids->{$uuid}) {
croak("UUID $uuid already met!");
}
eates a taxon list/table
=begin comment
Type : Wrapper
Title : _to_string
Usage : my $json_string = $obj->_to_string;
Function: Stringifies a Bio::Phylo object into an HTML string
Alias
ethod
Title : _json_data
Usage : $node->_json_data;
Function: Populates a data structure to be serialized as JSON
Returns :
Args :
=end comment
=cut
sub _json_data {
my $s
elf = shift;
my %result = %{ $self->SUPER::_json_data };
$result{'length'} = $self->get_branch_length if defined $self->get_branch_length;
$result{'rank'} = $self->get_rank if $se
lf->get_rank;
$result{'children'} = [ map { $_->_json_data } @{ $self->get_children } ];
return \%result;
}
=begin comment
Type : Internal method
Title : _cleanup
Usage : $tr
cy 'JSON';
use Bio::Phylo::Util::Dependency 'URI';
=head1 NAME
Bio::Phylo::Parsers::Tnrs - Parser used by Bio::Phylo::IO, no serviceable parts inside
=head1 DESCRIPTION
This module parses JSON out
taxa = $fac->create_taxa( '-namespaces' => { 'tnrs' => _NS_TNRS_ } );
my $data_structure = JSON::decode_json( do { local $/; <$fh> } );
my %authority;
# iterate over all returned names
for my $n
package App::Office::CMS::View::Search;
use strict;
use warnings;
use JSON::XS;
use Moo;
extends 'App::Office::CMS::View::Base';
our $VERSION = '0.93';
# ----------------------------------------
lt]};
}
else
{
$output = {results => [{site_name => "No names match '$name'"}]};
}
return JSON::XS -> new -> utf8 -> encode($output);
} # End of display.
# ----------------------------------
t=UTF-8',
'phyloxml' => 'application/xml;charset=UTF-8',
'nexus' => 'text/plain',
'json' => 'text/javascript',
'newick' => 'text/plain',
'fasta' => 'text/plain',
);
{
}
}
=item to_json()
Serializes object to JSON string
Type : Serializer
Title : to_json()
Usage : print $obj->to_json();
Function: Serializes object to JSON string
Returns : Str
Args : None
Comments:
=cut
sub to_json {
looks_like_class('Bio::Phylo::NeXML::XML2JSON')->new->convert( shift->to_xml );
}
sub _json_data {
my $self = shift;
my %meta =
ap { $_->get_predicate => $_->get_object } @{ $self->get_meta };
my %result = %{ $self->SUPER::_json_data };
$result{$_} = $meta{$_} for keys %meta;
$result{'name'} = $self->get_name if $self->g
of supported formats
Returns : [ qw(nexml nexus html json) ]
Args : NONE
=cut
sub get_supported_formats { [ 'nexml', 'html', 'json', 'nexus', 'rss1' ] }
=item get_redirect()
Gets a r
:Office::CMS::Util::Validator;
use File::Path 'make_path';
use File::Slurper 'write_text';
use JSON::XS;
use Path::Class; # For file().
use String::Dirify;
use Try::Tiny;
# We don't use Moo bec
ssage_div is on screen (under the Edit Content tab)
# because we're displaying content.
return JSON::XS -> new -> utf8 -> encode({results => $result});
} # End of backup.
# ----------------------
aying a page with an Edit button.
# It appears there by virtue of being within page.tx.
return JSON::XS -> new -> utf8 -> encode({results => $result});
} # End of display.
# ---------------------
::JSONFile -
=head1 SYNOPSIS
=head1 EXPORTS
Nothing exported by default
=over
=back
=head1 DEPENDENCIES
This module requires these other modules and libraries:
Perl::Module
JSON::
package Data::Hub::FileSystem::JSONFile;
use strict;
use Perl::Module;
use JSON::XS qw();
use base qw(Data::Hub::FileSystem::HashFile);
sub __parse {
my $tied = shift;
my $str = shift; # source s
ion hash
my $json = JSON::XS->new;
my $h = $$str ? $json->decode($$str) : {};
return overlay($data, $h);
}
sub __format {
my $tied = shift;
my $data = shift;
my $json = JSON::XS->new->asc
ii->pretty;
my $str = $json->encode(clone($data, -pure_perl));
return \$str;
}
sub __has_crown {
my $c = shift or return;
1;
}
1;
__END__
$$result .= _get_indent($level)._escape($value).$NEWLINE;
}
}
} elsif (isa($ref, 'JSON::XS::Boolean')) {
$$result .= _get_indent($level) .
$name.$SPACE.$LIT_ASSIGN.$SPACE.$
*HashFile\b');
# JSONFile
Add_Handler(q/Data::Hub::FileSystem::JSONFile/, '-type=!', '-path=\.json$');
Add_Handler(q/Data::Hub::FileSystem::JSONFile/, '-type=T', '-path=\.json$');
# YAMLFile
A
n '"' . $key . '"';
}
sub format_value {
my $self = shift;
my $value = shift;
isa($value, 'JSON::PP::Boolean') and return $value ? 'true' : 'false';
isa($value, 'SCALAR') and $value = $$value
rmats
Returns : [ qw(nexml nexus newick html json phyloxml rss1) ]
Args : NONE
=cut
sub get_supported_formats { [qw(nexml nexus newick html json phyloxml rss1)] }
=item get_authority()
Ge
ref of supported formats
Returns : [ 'nexml', 'json', 'nexus', 'rss1' ]
Args : NONE
=cut
sub get_supported_formats { [ 'nexml', 'json', 'nexus', 'rss1' ] }
=item get_authority()
G
$v if defined $v;
}
addr_join(@addrs) || '';
};
# JSON formatting
$Directives{'json'} = {};
$Directives{'json'}{'*'}[0] =
$Directives{'json'}{'var'}[0] = sub {
my $self = shift;
my $opts = m
$opts);
$self->get_ctx->{'collapse'} = 0;
js_format($value, -opts => $opts);
};
$Directives{'json'}{'string'}[0] = sub {
my $self = shift;
my $name = shift;
my $addr = shift;
my $text = $
to simple JSON. For a conversion to NeXML/JSON, use C<to_json>.
Type : Serializer
Title : to_js
Usage : my $json = $object->to_js;
Function: Serializes to JSON
Returns : A JSON string
A
rgs : None.
Comments:
=cut
sub to_js {JSON::to_json(shift->_json_data,{'pretty'=>1}) if looks_like_class 'JSON'}
sub _json_data {
my $self = shift;
my %data = %{ $self->