be Str/;
use JSON::MaybeXS;
use Moo::Role;
with 'Business::Giropay::Role::Network';
=head1 ATTRIBUTES
=head2 json
The json message data returned from giropay. Required.
=cut
has json => (
is
L</json> data converted to a hash reference.
=cut
has data => (
is => 'lazy',
isa => HashRef,
init_arg => undef,
);
sub _build_data {
return decode_json( shift->json );
= hmac_md5_hex( $self->json, $self->secret );
croak(
"Returned HMAC hash ", $self->hash,
" does not match expected hash ", $verify, " for json ", $self->json
) unless $verify
package OAuth::Lite2::Formatters;
use strict;
use warnings;
use OAuth::Lite2::Formatter::JSON;
use OAuth::Lite2::Formatter::XML;
use OAuth::Lite2::Formatter::FormURLEncoded;
use OAuth::Lite2::Format
S_BY_TYPE{$formatter->type} = $formatter;
}
__PACKAGE__->add_formatter( OAuth::Lite2::Formatter::JSON->new );
__PACKAGE__->add_formatter( OAuth::Lite2::Formatter::XML->new );
__PACKAGE__->add_formatt
ter = OAuth::Lite2::Formatter->get_formatter_by_name("json");
my $formatter = OAuth::Lite2::Formatter->get_formatter_by_type("application/json");
my $obj = $formatter->parse( $string );
$
se( $formatted_string );
=head1 SEE ALSO
L<OAuth::Lite2::Formatters>
L<OAuth::Lite2::Formatter::JSON>
L<OAuth::Lite2::Formatter::XML>
L<OAuth::Lite2::Formatter::FormURLEncoded>
=head1 AUTHOR
Lyo K
::AttributeShortcuts;
use Types::Standard qw/Str HashRef/;
use Types::URI qw/Uri/;
use JSON::MaybeXS 'decode_json';
use Path::Tiny;
with 'Badge::Depot';
has author => (
is => 'ro',
isa => St
sion,
};
}
return {} if !path('META.json')->exists;
my $json = path('META.json')->slurp_utf8;
my $data = decode_json($json);
return {} if !exists $data->{'name'} || !exi
sion> and C<dist> are set to the values in the Dist::Zilla object.
=item 2
If there is a C<META.json> in the distribution root then that is used to set C<version> and C<dist>.
=back
If neither of
gent(
join "/", __PACKAGE__, $OAuth::Lite2::VERSION);
}
$self->{format} ||= 'json';
$self->{response_parser} = OAuth::Lite2::Client::TokenResponseParser->new;
$self->{stat
phone at
L<https://secure.backblaze.com/account_settings.htm?showPhone=true>
=item 4. Create a JSON file named C<B2.credentials>
This file should live in your
home directory
with the application k
package WebService::Minecraft::Fishbans;
use 5.006;
use strict;
use Moo;
use LWP::UserAgent;
use JSON;
our $VERSION = '0.02';
=head1 NAME
WebService::Minecraft::Fishbans - look for bans for a Mine
{
die "Failed to query Fishbans - " . $response->status_line;
}
my $result = JSON::from_json($response->decoded_content)
or die "Failed to parse Fishbans response";
if (!$r
n optional feature offered by a CPAN
#pod distribution and specified in the distribution's F<META.json> (or F<META.yml>)
#pod file.
#pod
#pod For the most part, this class will only be used when opera
bes an optional feature offered by a CPAN
distribution and specified in the distribution's F<META.json> (or F<META.yml>)
file.
For the most part, this class will only be used when operating on the re
Auth::Lite2::Formatters>
L<OAuth::Lite2::Formatter::FormURLEncoded.pm>
L<OAuth::Lite2::Formatter::JSON>
L<OAuth::Lite2::Formatter::XML>
=head1 AUTHOR
Lyo Kato, E<lt>lyo.kato@gmail.comE<gt>
=head1 C
.008001;
use strict;
use warnings;
package Parse::CPAN::Meta;
# ABSTRACT: Parse META.yml and META.json CPAN metadata files
our $VERSION = '2.150010';
use Exporter;
use Carp 'croak';
our @ISA = qw/E
($meta);
}
elsif ($filename =~ /\.json$/) {
return $class->load_json_string($meta);
}
else {
$class->load_string($meta); # try to detect yaml/json
}
}
sub load_string {
my ($class
lass->load_yaml_string($string);
}
elsif ( $string =~ /^\s*\{/ ) { # looks like JSON
return $class->load_json_string($string);
}
else { # maybe doc-marker-free YAML
return $class->load
:Role::HasJSON;
use Moo::Role;
use JSON::MaybeXS;
our $VERSION = '0.001';
# Configure and cache the JSON object
has json => (
is => 'ro',
default => sub {
return JSON->new->utf
::API::V2::Role::HasJSON - Adds a json attribute with a JSON::MaybeXS
object
=head1 DESCRIPTION
Role for objects with JSON.
=head1 ATTRIBUTES
=over 4
=item json
Returns a JSON::MaybeXS object.
package Process::Results;
use strict;
use Carp 'croak';
use B;
use JSON::Tiny;
# debug tools
# use Debug::ShowStuff ':all';
# use Debug::ShowStuff::ShowVar;
# version
our $VERSION = '0.2';
# config
; # returns false
=item * json
You can pass in a json string which will be parsed and used to populate the new
object. For example:
$results = Process::Results->new(json=>'{"errors":[{"id":"no-fil
ults') {
return $opts{'results'};
}
}
# if json was sent, parse it
if ( $opts{'json'} ) {
$results = JSON::Tiny::decode_json($opts{'json'});
}
# else just create empty hashref
else {
package Ambassador::API::V2;
use Moo;
use v5.10;
with 'Ambassador::API::V2::Role::HasJSON';
use HTTP::Tiny;
use URI;
use Ambassador::API::V2::Error;
use Ambassador::API::V2::Result;
our $VERSION =
=> "Ambassador-API-V2/$VERSION",
default_headers => {'Content-Type' => 'application/json'}
);
}
);
sub _make_url {
my $self = shift;
my $method = shift;
my $u
sensitive to double slashes.
my $path = $url->path . join '/', $self->username, $self->key, 'json', $method;
$path =~ s{/{2,}}{/}g;
$url->path($path);
return $url;
}
sub _handle_re
use CPAN::Meta;
#pod use Module::Load;
#pod
#pod my $meta = CPAN::Meta->load_file('META.json');
#pod
#pod printf "testing requirements for %s version %s\n",
#pod $meta->name,
#pod
od
#pod =head1 DESCRIPTION
#pod
#pod Software distributions released to the CPAN include a F<META.json> or, for
#pod older distributions, F<META.yml>, which describes the distribution, its
#pod conten
ements for building and installing the distribution.
#pod The data structure stored in the F<META.json> file is described in
#pod L<CPAN::Meta::Spec>.
#pod
#pod CPAN::Meta provides a simple class to r
=> '5.006',
'File::Spec' => '0.86',
'JSON' => '2.16',
},
recommends => {
'JSON::XS' => '2.26',
},
suggests => {
'Archi
ctory to a file that contains or
generates the package. It may be given as C<META.yml> or C<META.json>
to claim a package for indexing without needing a C<*.pm>.
=item version
If it exists, this fi
N
Distribution metadata should be serialized (as a hashref) as
JSON-encoded data and packaged with distributions as the file
F<META.json>.
In the past, the distribution metadata structure had been p
::AttributeShortcuts;
use Types::Standard qw/Str HashRef/;
use Types::URI qw/Uri/;
use JSON::MaybeXS 'decode_json';
use Path::Tiny;
with 'Badge::Depot';
has dist => (
is => 'ro',
isa => Str,
sion,
};
}
return {} if !path('META.json')->exists;
my $json = path('META.json')->slurp_utf8;
my $data = decode_json($json);
return {} if !exists $data->{'name'} || !exi
sion> and C<dist> are set to the values in the Dist::Zilla object.
=item 2
If there is a C<META.json> in the distribution root then that is used to set C<version> and C<dist>.
=back
If neither of
; # returns false
=item * json
You can pass in a json string which will be parsed and used to populate the new
object. For example:
$results = Process::Results->new(json=>'{"errors":[{"id":"no-fil
<success> proeperty.
=head2 json()
C<< $results-E<gt>json() >> returns a JSON representation of the results object.
That's all, it takes no params, it just returns a JSON string.
OK, one minor thin
g to note is that the C<success> property is set to the JSON
value of C<true> or C<false>. Other then that, nothing complicated.
=head1 TERMS AND CONDITIONS
Copyright (c) 2016 by Miko O'Sullivan. Al
er
=item *
Revised spec examples as perl data structures rather than YAML
=item *
Switched to JSON serialization from YAML
=item *
Specified allowed version number formats
=item *
Replaced 're
onse;
use Moo::Role;
use Carp;
use Types::Standard ":types";
with 'Ambassador::API::V2::Role::HasJSON';
our $VERSION = '0.001';
has http_response => (
is => 'ro',
isa => HashRef,
required => 1,
);
sub _build_response {
my $self = shift;
my $content = eval { $self->json->decode($self->http_response->{content}); };
croak "Failed to decode @{[ $self->http_response
verter;
our $VERSION = '2.150010';
#pod =head1 SYNOPSIS
#pod
#pod my $struct = decode_json_file('META.json');
#pod
#pod my $cmc = CPAN::Meta::Converter->new( $struct );
#pod
#pod my $new_struc
eturn \$new;
}
# We can't know if TO_JSON gives us cloned data, so refs must recurse
if ( eval { $ref->can('TO_JSON') } ) {
my $data = $ref->TO_JSON;
return ref $data ? _dclone( $data )
data structures
=head1 VERSION
version 2.150010
=head1 SYNOPSIS
my $struct = decode_json_file('META.json');
my $cmc = CPAN::Meta::Converter->new( $struct );
my $new_struct = $cmc->convert(