package Flickr::API2::Raw;
use 5.12.0;
use warnings;
use JSON qw(decode_json);
use Digest::MD5 qw(md5_hex);
use Compress::Zlib;
use LWP::UserAgent;
use Retry;
use Encode;
use Carp qw(croak);
use paren
json = eval { decode_json($content) };
if ($@) {
croak("Failed to parse API response as JSON. Error=$@\nContent=$content\n");
}
if ( $json->{stat} eq 'ok' ) {
return $json
tage, I think.
}
croak(sprintf("API call failed: \%s (\%s)\n",
$json->{message}, $json->{code})
);
}
=head2 do_request
Calls LWP::UserAgent's ->request method, but does
ountebank::Types qw( HTTPHeaders );
use MooseX::Types::HTTPMethod qw(HTTPMethod11);
use JSON::Tiny qw(encode_json);
has method => ( is => 'ro', isa => HTTPMethod11 );
has path => ( is =>
ces/rest/';
bless $self, $class;
$self->{api_args}->{format} = 'json';
$self->{api_args}->{nojsoncallback} = 1;
$self->method('POST');
$self->uri( $self->{rest_uri} );
Calculate statistics on the availabity of the ISBN fields in the dataset
cat data.json | catmandu convert JSON to Stat --fields isbn
# Preprocess data and calculate statistics
catmandu co
ion;
use utf8;
use strict;
use warnings;
use boolean;
use feature 'state';
use URI ();
use JSON 'from_json';
use File::Slurp 'read_file';
use Salvation::TC ();
use MongoDB ();
sub new {
my (
if( defined( my $auth_config_file = $self -> auth_config_file() ) ) {
my $rv = from_json( scalar( read_file( $auth_config_file ) ) );
Salvation::TC -> assert( $rv, sprintf( 'Has
-> { 'servers_list' } = [ $self -> { 'host' } ];
} else {
my $config = from_json( scalar( read_file( $self -> config_file() ) ) );
Salvation::TC -> assert( $config,
Event );
use Net::Google::CalendarV3::Calendar;
use Net::Google::CalendarV3::Event;
use WWW::JSON;
use JSON::XS;
has authentication => is => 'ro', lazy => 1, predicate => 'has_auth', builder => '_bui
=> 1;
method _build_service {
WWW::JSON->new( base_url => 'https://www.googleapis.com/calendar/v3',
post_body_format => 'JSON',
( $self->has_auth
lf->has_token ? (authentication => $self->authentication) : () ),
json => JSON::XS->new->utf8->allow_nonref->allow_blessed->convert_blessed,
);
}
method _build_a
and a response
# (Responds to URL /foobar.json, returns JSON content '{"foo":"bar"}')
$imposter->stub->predicate(
path => "/foobar.json",
method => "GET",
)->response(
atus_code => 200,
content_type => "application/json",
# Equivalent:
# headers => { Content_Type => "application/json" },
body => { foo => "bar" },
#
->predicate(
path => "/qux/999/json",
method => "GET",
)->response(
status_code => 404,
content_type => "application/json",
body => '{ "error": "
read_text);
use Hash::DefHash;
use JSON::MaybeXS;
sub munge_files {
no strict 'refs';
my $self = shift;
find sub {
return unless -f && /\.json\z/;
my $ct = read_text $_;
my $hash;
eval { $hash = decode_json($ct) };
$self->log_fatal(["File %s doesn't contain a valid JSON: %s", "$File::Find::dir/$_", $@])
if $@;
my $defhash;
s>). Currently it does the following:
=over
=item * For C<share/examples/*.json>, check that the file contains valid JSON and valid defhash (or invalid defhash, if filename begins with 'error-')
=b
atalyst::TraitFor::Model::DBIC::Schema::QueryLog::AdoptPlack>.
use Plack::Builder;
use JSON;
use Plack::Debugger;
use Plack::Debugger::Storage;
use Plack::App::Debugger;
l',
serializer => sub { encode_json( shift ) },
deserializer => sub { decode_json( shift ) },
filename_fmt => "%s.json",
),
panels => [
Client;
use Moose;
our $VERSION = '0.001';
use Method::Signatures;
use HTTP::Tiny;
use JSON::Tiny qw(encode_json);
use Test::Mountebank::Imposter;
has ua => (
is => 'ro',
default => sub
) {
$self->ua->post(
$self->mb_url . "/imposters",
{
headers => { "Content-Type" => "application/json" },
content => $imp->as_json,
},
);
}
1;
Moose;
our $VERSION = '0.001';
use Method::Signatures;
use Test::Mountebank::Stub;
use JSON::Tiny qw(encode_json);
use Carp;
has protocol => ( is => 'rw', isa => 'Str', default => 'http' );
has port
[ $self->map_stubs( sub { $_->as_hashref } ) ],
protocol => $self->protocol,
port => $self->port,
};
}
method as_json() {
return encode_json( $self->as_hashref() );
}
1;
quire Carp;
$SIG{ __DIE__ } = \&Carp::confess;
$SIG{ __WARN__ } = \&Carp::cluck;
};
use JSON ();
use Getopt::Long 'GetOptions';
use Salvation::TC ();
use Salvation::MongoMgr ();
use Salvati
s );
my $json = JSON -> new() -> utf8( 1 ) -> allow_blessed( 1 );
if( $opts -> { 'pretty' } ) {
$json = $json -> pretty();
}
print( $json -> encode( $rv
get '/html' => sub {
send_as html => template 'foo';
};
get '/json/**' => sub {
send_as json => splat;
};
=head1 DESCRIPTION
This plugin is DEPRECATED. The C<send_as>
elds in the dataset
cat data.json | catmandu convert -v JSON to Stat --fields isbn
# Export the statistics as YAML
cat data.json | catmandu convert -v JSON to Stat --fields isbn --as YAML
a.json | catmandu convert JSON to Stat --fields title
# Calculate statistics on the number of records that contain a 'title', 'isbn' or 'subject' fields
cat data.json | catmandu convert JSON
t data.json | catmandu convert JSON to Stat --fields foo.bar.x.y
When no fields parameter is available, then all fields are read from the first input record.
=item as Table | CSV | YAML | JSON | ...
purged of any keys that are no longer relevant.
It should be safe to save this structure using L<JSON> or L<YAML> or L<MongoDB> or L<Storable> or whatever you like and load it again, if you want the
package Net::Google::CalendarV3::ToJson;
$Net::Google::CalendarV3::ToJson::VERSION = '0.16';
use Moose::Role;
use Kavorka;
method TO_JSON {
return { %$self };
};
1;
N = '0.001';
use Method::Signatures;
use Test::Mountebank::Types qw( HTTPHeaders );
use JSON::Tiny qw(encode_json);
use File::Slurper qw/read_text/;
use Carp;
use MIME::Types;
has status_code => (
tures;
use Test::Mountebank::Predicate::Equals;
use Test::Mountebank::Response::Is;
use JSON::Tiny qw(encode_json);
use Carp;
has predicates => (
traits => ['Array'],
is => 'ro',
is
map_responses( sub { $_->as_hashref } ) ],
predicates => [ $self->map_predicates( sub { $_->as_hashref } ) ],
};
}
method as_json() {
return encode_json( $self->as_hashref() );
}
1;
sub { shift->recipe->calc },
);
method TO_JSON {
+{ recipe => $self->recipe }
}
with 'App::vaporcalc::Role::Store';
1;
=pod
=for Pod::Coverage TO_JSON
=head1 NAME
App::vaporcalc::RecipeResult
$self->flavor_total }
method TO_JSON {
+{
map {;
my ($attr, $val) = ($_, $self->$_);
my $raw = blessed $val && $val->can('TO_JSON') ? $val->TO_JSON : $val;
$attr => $raw
flavors
/,
}
}
with 'App::vaporcalc::Role::Store';
1;
=pod
=for Pod::Coverage TO_JSON
=head1 NAME
App::vaporcalc::Result - A calculated App::vaporcalc::Recipe result
=head1 SYNOPSI