DateTime helpers.
=head1 DESCRIPTION
Support DateTime objects "natively" by making sure they TO_JSON-ify
properly, and provide some useful helper methods.
=cut
package App::Pebble::Helpers::DateTi
ings;
use DateTime;
use Carp;
=head2 METHODS
=cut
# Needed by Pebble::Object and JSON::XS
sub DateTime::TO_JSON {
my $self = shift;
"$self";
}
=head2 DateTime::round( $to_unit = "day" ) :
THODS
=head2 new()
Object constructor.
=head2 TO_JSON()
Returns HashRef that is possible to give to C<encode_json()> function.
=cut
sub TO_JSON {
my $self = shift;
return {
(
'title' => 'Bar chart test',
);
print $chart->render_swf(600, 400, 'chart-data.json', 'test-chart');
OFC2 bar chart data:
use Chart::OFC2;
use Chart::OFC2::Axis;
use C
lash
Chart 2 is offering. But it should help you to starting creating OFC2
graphs quite fast. The JSON format is quite intuitive and can be created
from any hash. This module is more like guideline.
2 is a flash script for creating graphs. To have a graph we need an
F<open-flash-chart.swf> and a JSON data file describing graph data.
Complete examples you can find after successful run of this modu
e LWP::UserAgent;
use HTTP::Request::Common();
use URI::PathAbstract;
use JSON;
our $json = JSON->new->pretty;
sub json { $json }
use WebService::Tumblr::Dispatch;
use WebService::Tumblr::Result;
us
arse matching lines into objects with named attributes.
# The default output format is one-line JSON.
cat lib/App/Pebble.pm | \
p 'P->match( regex => qr/^=head(\d+)\s+(.+)/, has => ["level", "te
ON
extends 'Chart::OFC2::BarLineBase';
In L<Chart::OFC2::HBarValues> when converting values to JSON the values are
reversed. This is done so that the C<y_axis->labels> match to the values.
Also not
THODS
=head2 new()
Object constructor.
=head2 TO_JSON()
Returns HashRef that is possible to give to C<encode_json()> function.
=cut
sub TO_JSON {
my $self = shift;
return {
map
li><a href="http://cpansearch.perl.org/src/JKUTEJ/Chart-OFC2-0.08_01/examples/for-pod/bar-data.json">json source</a></li>
</ul>
=end html
=cut
use Moose;
use MooseX::StrictConstructor;
our $VERSIO
THODS
=head2 new()
Object constructor.
=head2 TO_JSON()
Returns HashRef that is possible to give to C<encode_json()> function.
=cut
sub TO_JSON {
my ($self) = @_;
return {
m
THODS
=head2 new()
Object constructor.
=head2 TO_JSON()
Returns HashRef that is possible to give to C<encode_json()> function.
=cut
sub TO_JSON {
my $self = shift;
my %hash = (
kend(
$dsn,
serializer => KiokuDB::Serializer::Crypt->new(
serializer => 'json',
crypt_cipher => 'Rijndael',
crypt_mode => 'CFB',
crypt_key =
ration helpers.
=head1 DESCRIPTION
Support DateTime::Duration "natively" by making sure they TO_JSON-ify
properly, and provide some useful extra helper methods.
=cut
package App::Pebble::Helpers::
no warnings "redefine";
=head2 METHODS
=cut
# Needed by Pebble::Object and JSON::XS
sub DateTime::Duration::TO_JSON {
my $self = shift;
###TODO: replace with format duration
$self->in
is_max($max)
if defined $max;
}
=head2 TO_JSON()
Returns HashRef that is possible to give to C<encode_json()> function.
=cut
sub TO_JSON {
my $self = shift;
return {
THODS
=head2 new()
Object constructor.
=head2 TO_JSON()
Returns HashRef that is possible to give to C<encode_json()> function.
=cut
sub TO_JSON {
my $self = shift;
return {
li><a href="http://cpansearch.perl.org/src/JKUTEJ/Chart-OFC2-0.08_02/examples/for-pod/pie-data.json">json source</a></li>
</ul>
=end html
=cut
use Moose;
use MooseX::StrictConstructor;
our $VERSIO
s 'values' => (is => 'rw', isa => 'Chart::OFC2::PieValues', 'coerce' => 1,);
override 'TO_JSON' => sub {
my $self = shift;
my $pie_element = super();
# get the colours fr
nings;
use Pipe::Between::Object;
use LWP::UserAgent;
use HTTP::Request::Common qw(GET POST);
use JSON;
use utf8;
use Desktop::Notify;
use Encode::Guess qw/shiftjis euc-jp 7bit-jis/;
use Encode qw/fro
);
our $VERSION = '0.02';
# Preloaded methods go here.
our $ua = LWP::UserAgent->new;
our $json = JSON->new->allow_nonref;
sub new {#{{{
my $class = shift;
my $self = {
who => 'Net::Chaton::A
= POST($apilogin_url, [%postdata]);
my $responce = $ua->request($req);
my $decoded_responce = $json->decode($responce->content);
$self->{'post-uri'} = $decoded_responce->{'post-uri'};
$self->{'co
VERSION = '0.02';
use Carp;
use Data::Dumper;
use LWP::UserAgent;
use HTTP::Request::Common;
use JSON;
use vars qw(@AUTO_ATTRIBUTES @CLASS_ATTRIBUTES %DEFAULTS @EXPORT_OK);
use Class::AutoClass qw(
=@_;
my %args=(request_type=>'idtypes',
output_format=>'json');
my $content=$self->_fetch(%args);
my $table=decode_json($content);
wantarray? @$table:$table;
}
# reques
translate {
my ($self,%argHash)=@_;
my %args=(request_type=>'translate', output_format=>'json');
delete @argHash{keys %args}; # override values
@args{keys %argHash}=values %argHash if
traits => 'CatalystX::Controller::ExtJS::REST::SimpleExcel::Trait';
use strict;
use warnings;
use JSON::XS ();
after list => sub {
my ($self, $c) = @_;
return unless($c->request->accepts('app
$rcopy = $rcopy->{$1};
}
push(@row, ref $rcopy->{$hcopy} ? JSON::XS::encode_json($rcopy->{$hcopy}) : $rcopy->{$hcopy} );
}
push(@rows, \@row);
}
traits => 'CatalystX::Controller::ExtJS::REST::SimpleExcel::Trait';
use strict;
use warnings;
use JSON::XS ();
after list => sub {
my ($self, $c) = @_;
return unless($c->request->accepts('app
$rcopy = $rcopy->{$1};
}
push(@row, ref $rcopy->{$hcopy} ? JSON::XS::encode_json($rcopy->{$hcopy}) : $rcopy->{$hcopy} );
}
push(@rows, \@row);
}
too
=head1 METHODS
=head2 TO_JSON()
Returns HashRef that is possible to give to C<encode_json()> function.
=cut
sub TO_JSON {
my ($self) = @_;
my %json = (
map { my $v = $se
{ $_->name } $self->meta->get_all_attributes
);
$json{'3d'} = delete $json{'is3d'}
if (exists $json{'is3d'});
return \%json;
}
=head2 color()
Same as colour().
=cut
sub color