see L<Data::Clean::JSON>.
This property specifies postfilters for function result. Currently the focus of
this property is converting values that are unsafe when exporting to JSON/YAML.
Value: a ha
oder's facility, for example the L<JSON>
module can convert blessed object:
use JSON 2;
my $encoder = JSON->new->convert_blessed;
{
local *DateTime::TO_JSON = sub { $_[0]->ymd };
print $
encoder->encode($doc);
}
But this currently can't convert coderefs. JSON also can't handle circular
references, which neither this wrapper property nor the above way can work
around.
=head1 HOMEPAG
package WWW::AUR::RPC;
use warnings 'FATAL' => 'all';
use strict;
use JSON qw();
use Carp qw();
use WWW::AUR::URI qw( rpc_uri );
use WWW::AUR qw( _category_name _useragent );
my %_RENAME_FOR = ( '
'LastModified' => 'mtime',
);
#---HELPER FUNCTION---
# Purpose: Map JSON package info keys to their new names...
sub _munge_result
{
my ($info_ref) = @_;
my %res
info AUR RPC: ' . $resp->status_line
unless $resp->is_success;
my $json = JSON->new;
my $data = $json->decode( $resp->content );
if ( $data->{type} eq "error" ) {
Carp::
d::Signatures;
use namespace::autoclean;
extends 'WebService::SendGrid';
use URI;
use Carp;
use JSON::XS;
use Mail::RFC822::Address qw(valid);
has 'first_name' => ( is => 'rw', isa => 'Str', requir
e_request('/api/profile.get.json', {});
my $res = $self->_dispatch_request($req);
return $self->_process_error($res) if $res->code != 100;
my $content = ${ decode_json $res->content }[0];
# it
e_request('/api/profile.set.json', \%data);
my $res = $self->_dispatch_request($req);
return $self->_process_error($res) if $res->code != 200;
my $content = decode_json $res->content;
}
method
ry
throw_error
throw_immediate
formats
/]
);
use Clone qw(clone);
use JSON;
use JSV::Keyword qw(:constants);
use JSV::Reference;
use JSV::Context;
use Module::Pluggable::Ob
current_schema_pointer => "",
schema_pointer_history => [],
json => JSON->new->allow_nonref,
loose_type => $opts->{loose_type},
);
alidator;
}
1;
__END__
=encoding utf-8
=head1 NAME
JSV::Validator - A perl implementation of JSON Schema (draft-04) validator
=head1 SYNOPSIS
use feature qw(say);
use JSV::Validator;
JSV
ow_immediate
enable_history
enable_format
formats
history
json
loose_type
/],
ro => [qw/
errors
current_type
current_ke
current_schema_pointer
schema_pointer_history
/],
);
use Carp qw(croak);
use JSON;
use JSV::Keyword qw(:constants);
use JSV::Util::Type qw(detect_instance_type detect_instance_typ
ance {
my $self = shift;
my $instance;
if ( JSON::is_bool($self->current_instance) ) {
if ( $self->current_instance == JSON::true ) {
$instance = "true";
}
ge JSV::Reference;
use strict;
use warnings;
use Carp;
use Clone qw(clone);
use Data::Walk;
use JSON::Pointer;
use Scalar::Util qw(weaken);
use URI;
use URI::Split qw(uri_split uri_join);
my %memo;
e reference: uri = %s", $uri);
}
if ( $fragment ) {
eval {
$schema = JSON::Pointer->get($schema, $fragment, 1);
};
if (my $e = $@ ) {
die sprin
e Scalar::Util qw(blessed looks_like_number);
use JSON;
our @EXPORT_OK = (qw/
detect_instance_type
detect_instance_type_loose
escape_json_pointer
/);
our %REF_TYPE_MAP = (
HASH => "
if (!blessed $instance) {
return $REF_TYPE_MAP{$ref_type};
}
elsif (JSON::is_bool($instance)) {
return "boolean";
}
else {
croak(s
$/;
return "number_or_string";
}
}
return $type_strict;
}
sub escape_json_pointer {
my $property = shift;
return unless defined $property;
# according to http
oseX::WithCache;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Headers;
use HTTP::Message;
use JSON;
use Class::Date qw/gmdate/;
use POSIX; #strftime
use YAML qw/Dump LoadFile DumpFile/;
use Encode
g' => HTTP::Message::decodable ); # Enable compression
$h->header( 'Accept' => "application/json" );
my $data = $self->request_from_api(
headers => $h,
uri => 'ht
=> "application/json" );
$h->header( 'Accept-Encoding' => HTTP::Message::decodable ); # Enable compression
$h->header( 'Accept' => "application/json" );
$h->head
um;
use strict;
use warnings;
use parent qw(JSV::Keyword);
use JSV::Keyword qw(:constants);
use JSON;
use List::MoreUtils qw(firstidx);
sub instance_type() { INSTANCE_TYPE_ANY(); }
sub keyword() {
>keyword_value($schema);
my $instance_as_json = $context->json->encode($instance);
my $matched_idx = firstidx { $instance_as_json eq $context->json->encode($_); } @$enum;
if ($matched_idx
ackage JSV::Keyword::Draft4::Maximum;
use strict;
use warnings;
use parent qw(JSV::Keyword);
use JSON;
use JSV::Keyword qw(:constants);
sub instance_type() { INSTANCE_TYPE_NUMERIC(); }
sub keyword(
value($schema);
my $exclusive_maximum = $class->keyword_value($schema, "exclusiveMaximum") || JSON::false;
if ($exclusive_maximum) {
if ($instance >= $maximum) {
$context-
our $VERSION = "0.08";
1;
__END__
=encoding utf-8
=head1 NAME
JSV - A perl implementation of JSON Schema (draft-04) validator
=head1 SYNOPSIS
=head1 DESCRIPTION
See e.g. L<JSV::Validator>
=he
oudServers::Limits;
use LWP::ConnCache::MaxKeepAliveRequests;
use LWP::UserAgent::Determined;
use JSON;
use YAML;
use Carp;
our $DEBUG = 0;
has 'user' => (is => 'ro', isa => 'Str', required => 1)
s scalar grep { $response->code eq $_ } (200, 203);
my @servers;
my $hash_response = from_json($response->content);
warn Dump($hash_response) if $DEBUG;
# {"servers":[{"name":"test00"
ode
unless scalar grep { $response->code eq $_ } (200, 203);
my $hash_response = from_json($response->content);
warn Dump($hash_response) if $DEBUG;
confess 'response does not con
ngs;
use parent qw(JSV::Keyword);
use JSV::Keyword qw(:constants);
use JSV::Util::Type qw(escape_json_pointer);
use List::Util qw(first);
sub instance_type() { INSTANCE_TYPE_OBJECT(); }
sub keyword(
. "/" . escape_json_pointer( $property );
local $context->{current_schema_pointer} =
$context->{current_schema_pointer} . "/" . $class->keyword . "/" . escape_json_pointer( $prope
;
BEGIN { extends 'Catalyst::Controller' }
use JSON;
use Try::Tiny;
use namespace::autoclean;
__PACKAGE__->config(
'default' => 'application/json',
'stash_key' => 'response',
'map'
=> {
'application/x-www-form-urlencoded' => 'JSON',
'application/json' => 'JSON',
}
);
has 'root' => (
is => 'ro',
isa => 'Str',
default =
e} = {
"error" => "Failed to open directory '$full_path'",
"success" => JSON::false,
};
$c->detach('serialize');
};
my $regexp = $self->filter;
@
rver} . '/' . $call . '.json' => $header => json => $payload );
} elsif ( $mode eq 'delete' ) {
$tx = $ua->delete( $config->{server} . '/' . $call . '.json' => $header );
l . '.json' => $header => json => $payload );
} else {
my $combined_payload = { %$payload, %$params };
$tx = $ua->get( $config->{server} . '/' . $call . '.json' =>
bined_payload );
}
if ( my $res = $tx->success ) {
$response = $res->json;
} else {
warn 'fail';
p $tx->body;
my $err = $tx->er
pe qw(uri_escape);
use LWP::UserAgent;
use Carp qw(croak);
use Digest::SHA qw(sha256_base64);
use JSON;
=head1 NAME
WebService::Ooyala - Perl interface to Ooyala's API, currently only read
operation
path, $body, $params) = @_;
my $path = "/" . $self->{api_version} . "/" . $relative_path;
my $json_body = {};
my $url =
$self->build_path_with_authentication_params($http_method, $path,
$par
ailed to GET $full_url - " . $resp->status_line;
}
if ($resp->is_success) {
return decode_json($resp->decoded_content);
}
} else {
croak
"Trying to call a method that is not implemente
$n => $v;
}
} $self->meta->get_all_attributes
};
}
sub TO_JSON {
my ($self) = @_;
return $self->as_hash;
}
1;
__END__
=head1 NAME
Net::Amazon::EMR::
d::Signatures;
use namespace::autoclean;
extends 'WebService::SendGrid';
use URI;
use Carp;
use JSON::XS;
use DateTime::Format::HTTP;
use Mail::RFC822::Address qw(valid);
subtype 'Email', as 'Str',
headers' => ( is => 'rw', isa => 'HashRef', required => 0 );
# A collection of key/value pairs in JSON format
has 'date' => ( is => 'rw', isa => 'Str', required => 1, default => sub {
DateTime::Form
ate_request('/api/mail.send.json', \%data);
my $res = $self->_dispatch_request($req);
return $self->_process_error($res) if $res->code != 100;
my $content = decode_json $res->content;
}
1;
__E
interface to the SendGrid email service
use Moose;
use MooseX::Method::Signatures;
use Carp;
use JSON::XS;
use WWW::Curl::Simple;
use HTTP::Request;
has 'user_agent' => (
is => 'ro',
isa => 'WWW
ofile.get.json') {
my %profile = (
username => 'jlloyd',
email => 'jlloyd@cpan.org',
website_access => 'true',
active => 'true',
);
$content = encode_json( [ \%prof
ile ]);
}
else {
$content = encode_json( { message => 'success' });
}
my $res = HTTP::Response->new;
$res->code(100);
$res->content( $content );
return $res;
}
method _dispatch_r
V::Keyword);
use JSV::Keyword qw(:constants);
use JSV::Util::Type qw(detect_instance_type escape_json_pointer);
sub instance_type() { INSTANCE_TYPE_OBJECT(); }
sub keyword() { 'properties' }
sub add
nstance) {
local $context->{current_pointer} = $context->{current_pointer} . "/" . escape_json_pointer( $property );
if (exists $properties->{$property}) {
local $context-
nt_schema_pointer} =
$context->{current_schema_pointer} . "/properties/" . escape_json_pointer( $property );
$context->validate($properties->{$property}, $instance->{$prope