base 'Class::Accessor::Fast';
use MRO::Compat;
use mro "c3";
use Scalar::Util qw( blessed );
use JSON::XS ();
use Data::Dump qw( dump );
__PACKAGE__->mk_accessors(qw( datetime_format yui html_escape
RIPTION
CatalystX::CRUD::YUI::Serializer turns objects into hashrefs,
typically for rendering as JSON.
=head1 METHODS
Only new or overridden method are documented here.
=cut
=head2 new
Instanti
ams = { } ;
# new page
my $out = $obj->process( 'page', $content, $params) ;
# yamlasjson
$content = "list:
- array: [1,2,3,7]
channel: BBC3
date: 2013-10-20
annel: BBC4
date: 2013-11-20
time: 21:00
" ;
$out = $obj->process( 'yamlasjson', $content, $params) ;
# table
$content = "row1,entry 1,cell2
row2,cell1, entry 2
(Load);
use JSON;
use Moo;
use App::Basis::ConvertText2::Support;
use namespace::clean;
has handles => (
is => 'ro',
init_arg => undef,
default => sub { [qw{yamlasjson table versi
package URL::Social::BASE;
use Moose;
use namespace::autoclean;
use LWP::UserAgent;
use JSON;
=head1 NAME
URL::Social::BASE - Base class for the different social classes.
=head1 DESCRIPTION
You d
);
sub _build_useragent {
my $self = shift;
return LWP::UserAgent->new;
}
sub get_url_json {
my $self = shift;
my $url = shift || $self->url;
if ( $url =~ m,(file://.+), ) {
esponse = $self->useragent->get( $url );
if ( $response->is_success ) {
return JSON::decode_json( $response->content );
}
else {
return undef;
}
}
#
# The End
#
__PAC
:CRUD::Object );
# help for serialize()
use Rose::DB::Object::Helpers qw( column_values_as_json );
use JSON;
our $VERSION = '0.302';
=head1 NAME
CatalystX::CRUD::Object::RDBO - Rose::DB::Object im
DateTime
et al objects serialized to strings.
=cut
sub serialize {
return decode_json( column_values_as_json( shift->delegate ) );
}
1;
__END__
=head1 AUTHOR
Peter Karman, C<< <karman at cpa
r->{'Accept'} = $method if defined $accept;
$self->header->{'Accept'} = 'application/json' unless
defined $self->header->{'Accept'};
return $self->header->{'Accept'
.com/services/1.01/badge.getinfo?url=' . $self->url;
if ( my $json = $self->get_url_json($url) ) {
if ( my $data = $json->{result} ) {
return $data;
}
else {
t all the cookbooks available.
$obj->cookbook()->list;
=cut
# this module will be passed tha json parsed hash
# under ___data__() or variable.
# process it depending on the content expected.
su
base; #REST
pop @base; #CHEF
push @INC, '/', @base;
};
use parent qw { CHEF::REST };
use Mojo::JSON;
use Module::Load;
use vars qw { $AUTOLOAD };
sub new {
my $class = shift;
my $param = {@_};
lf = shift;
my $end_point = $self->api_end_point;
my $mojo_json = new Mojo::JSON();
my $list_of_roles =
$mojo_json->decode(
$self->ua( 'client_name' => $self->name
my $url = 'http://www.reddit.com/api/info.json?url=' . $self->url;
if ( my $json = $self->get_url_json($url) ) {
if ( my $data = $json->{data} ) {
if ( my $children = $d
shift;
my $url = 'http://cdn.api.twitter.com/1/urls/count.json?url=' . $self->url;
if ( my $share_count = $self->get_url_json($url)->{count} ) {
return $share_count || 0;
}
package Mojolicious::Plugin::Args;
use Mojo::Base 'Mojolicious::Plugin';
use Mojo::JSON 'decode_json';
sub register {
my ( $self, $app, $opts ) = @_;
$opts->{ '-want-detail' } //= 0 unless ex
n/json' ) or
( $c->req->method eq 'GET' and defined $stash->{format} and $stash->{format} eq 'json' and defined $args{json} ) ) {
my @args = keys %args;
my $json =
decode_json( $c->req->method eq 'GET' ? delete $args{json} : $c->req->body );
my @json = keys %{ $json };
do {
$args{__args}->{ $_ } = $args{ $_ } for @args;
:attributes;
$CHEF::REST::Client::environments::VERSION = 1.0;
# this module will be passed tha json parsed hash
# under ___data__() or variable.
# process it depending on the content expected.
su
nt FROM link_stat WHERE url = "' . $self->url . '"';
if ( my $json = $self->get_url_json($url) ) {
if ( my $data = $json->{data}->[0] ) {
return $data;
}
else
ZimbraManager;
use Mojo::Base 'Mojolicious';
use Mojo::Util qw(dumper);
use Mojo::JSON qw(decode_json encode_json);
use ZimbraManager::SOAP;
use ZimbraManager::SOAP::Friendly;
use HTTP::CookieJar
$ctrl->render(text => "<pre>$text</pre>") if ($plain);
}
else {
$ctrl->render(json => $text);
}
};
my $buildAuthRequest = sub {
my $user = shift;
my $password = shi
g
$r->post('/auth' => sub {
my $ctrl = shift;
my $perl_args = decode_json($ctrl->req->body);
my $user = $perl_args->{'user'};
my $password = $per
*to_string = \&value;
sub get_time {
return hex(substr($_[0]->{value}, 0, 8));
}
sub TO_JSON { {'$oid' => $_[0]->{value}} }
use overload
'""' => \&to_string,
'fallback' => 1;
1;
he timestamp.
=head2 TO_JSON
my $json = JSON->new;
$json->allow_blessed;
$json->convert_blessed;
$json->encode(MongoDB::Async::OID->new);
Returns a JSON string for this OID. Thi
s is compatible with the strict JSON
representation used by MongoDB, that is, an OID with the value
"012345678901234567890123" will be represented as
C<{"$oid" : "012345678901234567890123"}>.
=head
ection in your main file in your distribution, this L<Dist::Zilla>
plugin will populate your META.json x_contributors list from it.
The format should be:
Some Name <some@email.com>
nicknames are
RESTModel:
MyData:
server: http://localhost:5000
type: application/json
clientattrs:
timeout: 5
then use it from any of your routes/controllers:
d2 result_as_json()
Same as C<result()>, except converts the data into JSON notation
=cut
sub result_as_json {
my $self = shift;
require JSON;
return JSON::to_json( $self->resu
##########################################
# sexp encoding
# (This code is based on Mojolicious's JSON library.)
# Translate an argument object into S-expression text.
sub to_sexp {
my $arg = shift
=> $violation->explanation,
diagnostics => $violation->diagnostics,
};
}
$self->render( json => \@results );
}
sub _capture_cmd_output {
my $self = shift;
my $cmd = shift;
my $opts
aram('input');
my $o = $self->_capture_cmd_output( $^X, [], $source, $input );
$self->render( json => $o );
}
sub run_perlbrew_exec {
my $self = shift;
my $source = $self->param('source');
m
$self->_capture_cmd_output( 'perlbrew', [ 'exec', 'perl' ],
$source, $input );
$self->render( json => $o );
}
# Taken from Padre::Plugin::PerlTidy
# TODO document it in 'SEE ALSO' POD section
sub