est::Mojo->new('<%= $p->{class} %>');
$t->post_ok('/jsonrpc','{"id":1,"service":"<%= $p->{name} %>","method":"ping","params":["hello"]}')
->json_is('',{id=>1,result=>'got hello'},'post request');
r" perl scripts/log.pl
use strict;
use warnings;
use Curses::UI;
use Data::Dumper;
use JSON::Tiny qw(encode_json);
use Data::Faker;
use Log::Log4perl;
use Log::Log4perl::DataDumper;
use Log::Log4
thods)
{
$data{$_} = $faker->$_();
}
my $l = {};
$l->{'json'} = encode_json(\%data);
$l->{'dumper'} = Dumper(%data);
$l->{raw} = \%data;
$log->debug($l)
package BlankOnDev::config::save;
use strict;
use warnings FATAL => 'all';
# Import Module :
use JSON::XS;
use BlankOnDev::Utils::file;
# Version :
our $VERSION = '0.1005';
# Subroutine save key co
-
sub save_to_file {
my ($self, $filename, $dir_dev, $data) = @_;
my $data_file = encode_json($data);
my $create_file = BlankOnDev::Utils::file->create($filename, $dir_dev, $data_file);
2 app.
use strict;
use warnings;
use Dancer2::Plugin;
use Dancer2::Plugin::Cart::InlineViews;
use JSON;
our $VERSION = '1.0001'; #Version
BEGIN{
has 'product_list' => (
is => 'ro',
from_c
$self->mainstore( _defined_or( $hash{mainstore}, $cfg->val('MASTER','mainstore' ), 'cpanstats-%s.json' ));
$self->templates( _defined_or( $hash{templates}, $cfg->val('MASTER','templates' ) ));
to manage the creation of all the statistics graphs.
=item * storage
Method to return specific JSON data currently stored.
=cut
__PACKAGE__->mk_accessors(
qw( directory mainstore templates ad
i.
sudo cpan -i Crypt::Blowfish Digest::MD5
sudo cpan -i MIME::Base64 MIME::Base64::Perl JSON DateTime
sudo cpan -i GnuPG Hash::MultiValue Term::ReadKey LWP::UserAgent
sudo cpan -i Te
pec qw/catfile/;
use Getopt::Long;
use Path::Tiny;
use Hash::Flatten;
use Cwd;
use Net::Etcd;
use JSON;
use YAML::Syck;
use Path::Class qw( file );
use File::Spec;
use Try::Tiny;
use Data::Dumper;
us
-json=json2
--runtime=standard
--runtime=lite Same as --ajax=none --json=none
--runtime=jquery Same as --ajax=jquery --json=none
--runtime=yui Same as --ajax=yui --json=
ajax=gregory --json=json2
--json By itself, equivalent to --json=json2
--json=json2 Include http://www.json.org/json2.js for parsing/stringifying
--json=yui U
se YUI: YAHOO.lang.JSON (requires external YUI)
--json=none Doesn't provide any JSON functionality except a warning
--ajax By itself, equivalent to --ajax=xhr
--ajax=
se warnings;
use Carp qw(croak);
use HTTP::Request::Common qw(GET POST);
use LWP::UserAgent;
use JSON::MaybeXS;
use URI;
use URI::Escape;
use URI::QueryParam;
use WebService::Google::Reader::Constan
y, %fields, output => 'json' });
my $req = HTTP::Request->new(GET => $uri);
my $res = $self->_request($req) or return;
my @ids = do {
my $ref = eval { JSON->new->decode($res->dec
oded_content) } or do {
$self->error("Failed to parse JSON response: $@");
return;
};
map { $_->{id} } @{$ref->{results}};
};
return unless @ids;
if
my %auth_params = (
Timestamp => sprintf("%s", DateTime->now()),
Format => 'JSON',
Version => $Version,
SignatureMethod => 'HMAC-SHA1',
SignatureVersio
\%auth_params );
$tx = $self->ua->start($tx);
return $tx->res->json if ($tx->res->headers->content_type || '') =~ /json/;
my $err = $tx->error;
croak "$err->{code} response: $err->{m
ar2GitHub;
use strict;
use warnings FATAL => 'all';
# Import Module :
use Data::Dumper;
use JSON;
use JSON::XS;
use Term::ReadKey;
use Hash::MultiValue;
use BlankOnDev::DateTime;
use BlankOnDev::Util
my ($new_config) = @_;
# Create File :
my $newData_cfg = encode_json($new_config);
BlankOnDev::Utils::file->create($file_name, $dir_dev, $newData_cfg);
my ($new_config) = @_;
# Create File :
my $newData_cfg = encode_json($new_config);
BlankOnDev::Utils::file->create($file_name, $dir_dev, $newData_cfg);
v::config;
use strict;
use warnings FATAL => 'all';
# Import Module :
use Data::Dumper;
use JSON;
use JSON::XS;
use UNIVERSAL::ref;
use Hash::MultiValue;
use Term::ReadKey;
use GnuPG qw( :algo );
use
my $data_cfg = decode_json($get_cfg);
$data = $data_cfg;
} else {
BlankOnDev::Utils::file->create($file_name, $dir_dev, encode_json($format_config));
e {
mkdir($dir_dev);
BlankOnDev::Utils::file->create($file_name, $dir_dev, encode_json($format_config));
$data = $format_config;
}
$gencfg = $data;
}
# Subroutine for
Or
prove -PTest::DB::Shared::mysqld=./testmysqld.json
The ./testmysqld.json file can contain the arguments to Test::DB::Shared::mysqld in a json format (see SYNOPSIS). They
will be used to build o
tate.
=head1 METHODS
=cut
use Moo;
use Carp qw/confess/;
use Log::Any qw/$log/;
use DBI;
use JSON;
use Test::mysqld;
use File::Slurp;
use File::Spec;
use File::Flock::Tiny;
use POSIX qw(SIGTERM
nfess("Cannot find config file $config_file");
}else{
$config = JSON::decode_json( scalar( File::Slurp::read_file( $config_file, { binmode => ':raw' } ) ) );
}
type.getJSON
Prototype.getJSON(url, callback)
based on: getJSON function by Juriy Zaytsev L<http://github.com/kangax/protolicious/tree/master/get_json.js>
A method to temporarily load JSON data (
ideally hosted on a different domain and accessible via JSONP service) and send it over to callback method when ready.
=head2 Hash utilities
=head3 Hash.expand
var tree = Hash.expand(flat_hash);
use strict;
use warnings;
use CGI;
use HTTP::Daemon;
use HTTP::Status;
use URI::Escape;
use JSON;
use Encode qw/decode_utf8/;
my $query;
my @countries = <DATA>;
chomp foreach @countries;
my $port =
code => $c, } } @countries_list;
my $json = to_json(\@choices, {ascii => 1});
print STDERR "RESPONSE: $json\n";
my $response = HTTP::Response->new(RC_OK);
'Pragma' => 'no-cache',
'Expires' => '0');
$response->content($json);
$client_connection->send_response($response);
}
elsif ($path_info =~ s[^g/country
then an Ajax request
will be sent to C</myapp/completion?search=ab>.
The server should return a JSON array, in the format explained below.
=item a callback function
That function will be called, w
See also C<options.caseSensitive>.
=item an object (JSONP)
Useful when accessing data on a different domain via JSONP services.
Ex : { json_url: 'http://search.yahooapis.com/WebSearchService/V
&query=?1&output=json&callback=?2',
json_list: 'ResultSet/Result' }
The object should hold details of the JSONP service to be called.
C<json_url> : url to call with placeholders (?1, ?2)
se Moo;
use Types::Standard qw<Str ArrayRef InstanceOf>;
use namespace::autoclean;
use Carp;
use JSON::MaybeXS 1.001000;
use Try::Tiny;
use HTTP::Tiny 0.014;
with qw/
MetaCPAN::API::Author
M
AN::API::VERSION || 'xx';
return [ agent => "MetaCPAN::API/$version" ];
},
);
my $JSON = JSON::MaybeXS->new(canonical => 1, utf8 => 1);
sub _build_ua {
my $self = shift;
return H
my $query_json = $JSON->encode( $query );
my $result = $self->ua->request(
'POST',
"$base/$url",
{
headers => { 'Content-Type' => 'application/json' },
OpusVL::SysParams::Schema::ResultSet::SysInfo;
use Moose;
extends 'DBIx::Class::ResultSet';
use JSON;
sub ordered
{
my $self = shift;
my $me = $self->current_source_alias;
return $self
my $info = $self->find_or_new({
name => $name,
});
$info->set_column(value => JSON->new->allow_nonref->encode($value));
if ($data_type) {
$info->set_column(data_type =>
lf = shift;
my $name = shift;
my $info = $self->find
({
name => $name
});
return $info ? JSON->new->allow_nonref->decode($info->value) : undef;
}
sub del
{
my $self = shift;
my $name = sh
package OpusVL::SysParams;
use warnings;
use strict;
use JSON;
use Data::Munge qw/elem/;
use Moose;
has 'schema' => (isa => 'DBIx::Class::Schema', is => 'ro', required => 1,
default => sub
ltset('SysInfo')->set(@_);
}
sub set_json {
my $self = shift;
my $name = shift;
my $val = shift;
my $schema = $self->schema;
my $obj = JSON->new->allow_nonref->decode($val);
ame, $obj);
}
sub get_json {
my $self = shift;
my $schema = $self->schema;
my $val = $schema->resultset('SysInfo')->get(@_);
return if !$val;
return JSON->new->allow_nonref->enc
l_display_here',
toolbar_container: 'grid_toolbar_will_display_here',
dto: {VUE: 'JSON'},
columns: [
{label: 'Full Name', value: function(e) {
retu
ESCRIPTION
Displays a dataset in a grid format.
Dataset is bound to a JSON datasource retrieved via an AJAX request.
JSON object has a predefined format that the Grid class understands and rende
ast page correspondingly.
=back
=head1 JSON Datasource
As mentioned before, the Grid expects the JSON datasource object to be of a predefined format.
json = {
'liste' : [
{'fname':