er::Scenarios::JSONDecodeRegexp;
our $DATE = '2017-01-25'; # DATE
our $VERSION = '0.003'; # VERSION
use 5.010001;
use strict;
use warnings;
1;
# ABSTRACT: Scenarios to benchmark JSON::Decode::Regex
1 NAME
Bencher::Scenarios::JSONDecodeRegexp - Scenarios to benchmark JSON::Decode::Regexp
=head1 VERSION
This document describes version 0.003 of Bencher::Scenarios::JSONDecodeRegexp (from Perl dis
er-Scenarios-JSONDecodeRegexp), released on 2017-01-25.
=head1 DESCRIPTION
This distribution contains the following L<Bencher> scenario modules:
=over
=item * L<Bencher::Scenario::JSONDecodeRegexp
package Bencher::Scenario::JSONDecodeRegexp::Startup;
our $DATE = '2017-01-25'; # DATE
our $VERSION = '0.003'; # VERSION
use 5.010001;
use strict;
use warnings;
our $scenario = {
summary => 'Be
nchmark startup overhead of JSON::Decode::Regexp vs some other modules',
module_startup => 1,
participants => [
{module=>'JSON::Decode::Regexp'},
{module=>'Regexp::Grammars'},
up overhead of JSON::Decode::Regexp vs some other modules
__END__
=pod
=encoding UTF-8
=head1 NAME
Bencher::Scenario::JSONDecodeRegexp::Startup - Benchmark startup overhead of JSON::Decode::Regex
R::JSONDecodeRegexp;
our $VERSION = 0.003; # VERSION
our $results = [
[
200,
"OK",
[
{
errors => 1.9e-07,
modver => 0.06,
participant => "JSON::
Decode::Regexp::from_json",
rate => 11000,
samples => 24,
time => 87,
vs_slowest => 1,
},
{
errors => 1.9e-07,
modve
r => 0.03,
participant => "JSON::Decode::Regexp::from_json",
rate => 17000,
samples => 20,
time => 60,
vs_slowest => 1.4,
},
STRACT: Perl API Bindings to the OSI License API
use Moo;
use REST::Client;
use Const::Fast;
use JSON;
use Carp;
const my $base_url => 'https://api.opensource.org';
has _api_client => ( is => 'lazy
();
my $response = shift();
if ( $response->responseCode() == 200 ) {
return from_json( $response->responseContent );
} else {
croak 'Error: ' . $response->responseCode() .
THODS
=head2 all
Get a list of all known licenses.
The response is the perl equivalent of the json returned by the api,
documented in L<https://github.com/OpenSourceOrg/api/blob/master/doc/endpoin
::Scenario::JSONDecodeRegexp;
our $DATE = '2017-01-25'; # DATE
our $VERSION = '0.003'; # VERSION
use 5.010001;
use strict;
use warnings;
our $scenario = {
summary => 'Benchmark JSON decoding',
mplate => 'JSON::Decode::Regexp::from_json(<data>)',
},
{
module => 'JSON::PP',
function => 'decode',
code_template => 'state $json = JSON::PP->new-
>allow_nonref; $json->decode(<data>)',
},
],
datasets => [
{name => 'str-a' , args=>{data=>'"123456789012345678901234567890123456789012345678901234567890123456789012345678901
package Swagger2::SchemaValidator;
use Mojo::Base 'JSON::Validator::OpenAPI';
warn "# Swagger2::SchemaValidator is deprecated in favor of JSON::Validator::OpenAPI";
1;
=encoding utf8
=head1 NAME
Sw
Validator - DEPRECATED
=head1 DEPRECATION WARNING
See L<Swagger2>.
=head1 DESCRIPTION
Use L<JSON::Validator::OpenAPI> instead.
=head1 SEE ALSO
L<Swagger2> and L<JSON::Validator::OpenAPI>.
=cut
Grab;
use YAML::Tiny;
use WWW::Mechanize;
use Crypt::SSLeay;
use Digest::Perl::MD5 'md5_hex';
use JSON;
use error_codes;
sub readConfig {
my $conf = YAML::Tiny->read( 'config.yaml' );
return
} else {
%config = (%config, %timestamp);
};
my @o_formats = ('xml', 'json');
my $request_json; my $request_xml;
foreach my $format (@o_formats) {
$config{return} = $fo
f-8', raw => 1);
$request_json = $request if $format eq 'json';
$request_xml = $request if $format eq 'xml';
};
my $r = from_json($request_json);
my @error;
if ($r->{er
package Swagger2::Client;
use Mojo::Base -base;
use Mojo::JSON;
use Mojo::UserAgent;
use Mojo::Util;
use Carp ();
use Swagger2;
use JSON::Validator::OpenAPI;
use constant DEBUG => $ENV{SWAGGER2_DEBU
t->_swagger->base_url) };
has ua => sub { Mojo::UserAgent->new };
has _validator => sub { JSON::Validator::OpenAPI->new; };
sub generate {
my $class = shift;
my ($swagger, $url) = _swagge
es = Mojo::Message::Response->new;
$res->headers->content_type('application/json');
$res->body(Mojo::JSON::encode_json({errors => $_[0]}));
$res->code(400)->message($res->default_message);
$re
se Mojo::Base -base;
use Mojo::Asset::File;
use Mojo::JSON;
use Mojo::JSON::Pointer;
use Mojo::URL;
use File::Basename ();
use File::Spec;
use JSON::Validator::OpenAPI;
our $VERSION = '0.89';
# Shou
= shift;
return $self->_validator->_load_schema($self->url) if '' . $self->url;
return Mojo::JSON::Pointer->new({});
};
has base_url => sub {
my $self = shift;
my $url = Mojo::URL->new;
m
pecification => sub { shift->_validator->schema('http://swagger.io/v2/schema.json')->schema };
has _validator => sub { JSON::Validator::OpenAPI->new };
sub ua { shift->_validator->ua(@_) }
sub url
a_fields = $self->db->users_extra_fields->get_all(
fields => [qw(user_id key value is_json)],
filter => {user_id => array_uniq(map {$_->{'id'}} @$result)}
);
f
ields->{'__EXTRA_FIELDS__'}{$rec->{'user_id'}}{$rec->{'key'}}},
$rec->{'is_json'} ? from_json($rec->{'value'}) : $rec->{'value'}
);
}
}
}
sub add {
my ($se
ta,
map {{user_id => $id, key => $key, value => $_->{'value'}, is_json => $_->{'is_json'}}}
@{$extra_fields->{$key}});
}
if($c->debug) {
require JSON::MaybeXS;
my $json_with_args = JSON::MaybeXS->new(utf8 => 1, allow_nonref=>1);
$find = scalar(@find) ? $json_with_args->encode(@find) : '[NEW
initializing = false;
ace.session.setMode("ace/mode/" + (ace.getValue().match(/^\s*\{/) ? "json" : "yaml"));
preview.scrollTop = scrollSave();
};
var render = function() {
scrollSa
Editor> is a WEB based Swagger2 API editor.
=head1 SYNOPSIS
$ mojo swagger2 edit /path/to/api.json --listen http://*:3000
=head1 ATTRIBUTES
=head2 specification_file
Returns path to swagger spe
render the POD if requested as C</.txt> instead.
=head2 POST /
Will L<parse|Swagger/parse> the JSON/YAML in the HTTP body and render it as POD.
=head1 METHODS
=head2 startup
Used to set up the L
my $args = {@_};
return $self->get_data(method => 'GET', path_template => "$base_uri/events.json", parameters => $args);
}
=head2 event_details
Returns the event details by event ID.
Also See
provided\n");
return $self->get_data(method => 'GET', path_template => "$base_uri/events/$id.json", parameters => $args);
}
=head2 event_images
Returns all event images by event ID.
Also See:
d\n");
return $self->get_data(method => 'GET', path_template => "$base_uri/events/$id/images.json", parameters => $args);
}
=head2 search_attractions
Returns available attactions
Also See: htt
package Ticketmaster::API;
use 5.006;
use strict;
use warnings;
use Carp;
use JSON::XS;
use LWP::UserAgent;
=head1 NAME
Ticketmaster::API - start interacting with Ticketmaster's APIs
=head1 VERSI
d => $uri);
my $res = $ua->request($req);
if ($res->is_success) {
return decode_json($res->content);
}
else {
Carp::croak("Error: " . $res->status_line);
}
}
=he
ion => $VERSION,
base => 'XAS::Singleton',
accessors => 'spooler',
codec => 'JSON',
utils => ':validation',
filesystem => 'Dir'
;
# -------------------------------------
y => $self->env->facility,
message => $message,
};
my $json = encode($data);
$self->spooler->write($json);
}
# ----------------------------------------------------------------
b action {
my $self = shift();
my $mongo = $self->mongodb();
...
return $self->render( json => undef );
}
Just in case you need access to the MongoDB client instance you can use this help
ants
constant => {
# generic
LF => "\012",
CR => "\015",
# JSON RPC
RPC_JSON => '2.0',
RPC_DEFAULT_ADDRESS => '127.0.0.1',
RPC_DEFAULT_PORT
LOG_LEVELS => qr/info|warn|error|fatal|debug|trace/,
LOG_TYPES => qr/console|file|json|syslog/,
LOG_FACILITY => qr/auth|authpriv|cron|daemon|ftp|local[0-7]|lpr|mail|news|user|uuc
LOCK_DRIVERS => qr(Flom|Filesystem|Nolock|KeyedMutex),
},
exports => {
all => 'RPC_JSON RPC_DEFAULT_PORT RPC_DEFAULT_ADDRESS RPC_ERR_PARSE
RPC_ERR_REQ RPC_ERR_METHOD RPC_
package WWW::Deezer;
use strict;
use warnings;
use Carp();
use LWP::UserAgent;
use JSON;
use URI::Escape;
use WWW::Deezer::SearchResult;
use WWW::Deezer::Artist;
our $VERSION = '0.03';
our $API_VE
rl => "http://api.deezer.com/$API_VERSION/",
ua => LWP::UserAgent->new,
json => JSON->new->allow_nonref,
debug => 0,
};
$self->{ua}->agent("WWW::Deezer v".$V
_get_url ({
url => $uri.'/'.$id,
method => 'GET'
});
$res = $self->{json}->decode ($res) unless _is_hashref ($res);
$res->{deezer_obj} = $self;
return WWW::Deeze
redefine';
my @booleans = (
'JSON::PP::Boolean',
'JSON::XS::Boolean',
'Types::Serialiser::Boolean', # should not be needed
'Mojo::JSON::_Bool', # only up to Mojol
icious 6.21
# Dancer, Dancer2 use JSON
);
sub YAML::Tiny::dumper_for_unknown {
my ($self, $element, $line, $indent, $seen) = @_;
my $type = ref $element;
for my $boolean
1,
default => \&DEFAULT_records,
);
has JSON_decoder => (
is => 'rw',
lazy => 1,
default => sub {
for my $module (qw< JSON JSON::PP >) {
(my $filename = "$module.p
a => 'Int';
has 'nb_fan', is => 'rw', isa => 'Int';
has 'radio' => (
is => 'ro',
isa => 'JSONBoolean',
coerce => 1
);
around BUILDARGS => sub { # allow create Artist object with single a
$self = WWW::Deezer->new->artist($_[0]);
}
else {
# 2DO: deal with Bool and JSON::XS::Boolean=\1 in 'radio' argument
$self = $class->$orig(@_);
}
return $self;
};