sa(IO::Async::Notifier) :strict(params) {
use JSON::MaybeXS qw//;
use Net::Async::HTTP;
use Feature::Compat::Try;
use URI;
field $_json = JSON::MaybeXS->new(utf8 => 1, convert_blessed => 1)
headers => {
"Authorization" => "Bearer $api_key",
"Content-Type" => "application/json",
$api_org_name ? (
'OpenAI-Organization' => $api_org_name,
) : ()
my $json = $_json->encode($data);
my $url = URI->new($api_base . $endpoint );
my $result = await $http->do_request(
uri => $url,
method => "POST",
content => $json,
package Object::PadX::Role::AutoJSON;
use v5.26;
use strict;
use warnings;
use Object::Pad ':experimental(custom_field_attr mop)';
use Object::Pad::MOP::FieldAttr;
use Object::Pad::MOP::Field;
use
r->register( "JSONExclude", permit_hintkey => 'Object::PadX::Role::AutoJSON', apply => $_disallow_value );
# Set a new name when going to JSON
Object::Pad::MOP::FieldAttr->register( "JSONKey", permit_
utoJSON', apply => $_require_value );
# Allow this to get sent as null, rather than leaving it off
Object::Pad::MOP::FieldAttr->register( "JSONNull", permit_hintkey => 'Object::PadX::Role::AutoJSON',
3-11-14
=head1 SYNOPSIS
use Object::Pad;
use Object::PadX::Role::AutoMarshal;
use Cpanel::JSON::XS;
class Pet {
field $name :param;
field $species :param = "Dog";
}
class Perso
shal) {
...
}
This is the only import right now, it creates a top level namespace role AutoJSON for lazy people (like me).
This is a bad idea, don't do it it pollutes this globally since there
fo
=head1 LICENSE
This module is available under the Artistic 2.0 License
=head1 SEE ALSO
L<Object::Pad>, L<Cpanel::JSON::XS>
=head1 AUTHOR
Ryan Voots, L<simcop@cpan.org>, aka simcop2387
=cut
sa(IO::Async::Notifier) :strict(params) {
use JSON::MaybeXS qw//;
use Net::Async::HTTP;
use Feature::Compat::Try;
use URI;
field $_json = JSON::MaybeXS->new(utf8 => 1, convert_blessed => 1)
headers => {
"Authorization" => "Bearer $api_key",
"Content-Type" => "application/json",
$api_org_name ? (
'OpenAI-Organization' => $api_org_name,
) : ()
my $json = $_json->encode($data);
my $url = URI->new($api_base . $endpoint );
my $result = await $http->do_request(
uri => $url,
method => "POST",
content => $json,
&facet.field=fedora.model&facet.mincount=1&facet.sort=count&facet.limit=100&facet.offset=0&rows=0&json.facet=%7Bx:%22unique(fedora.model)%22%7D
sub search {
my ($self, $opts_hr) = @_;
$self->_valid
ancer2::Serializer::JsonApi;
our $AUTHORITY = 'cpan:YANICK';
$Dancer2::Serializer::JsonApi::VERSION = '0.0.1';
use Dancer2::Plugin::JsonApi::Registry;
use Dancer2::Serializer::JSON;
use Moo;
has co
lication/vnd.api+json' );
with 'Dancer2::Core::Role::Serializer';
has registry => (
is => 'rw',
default => sub { Dancer2::Plugin::JsonApi::Registry->new }
);
has json_serializer => (
=> 'ro',
default => sub { Dancer2::Serializer::JSON->new }
);
sub serialize {
my ( $self, $data ) = @_;
return $self->json_serializer->serialize(
$self->registry->serializ
endpoint
Expands the selected URI via L<URI::Template>. Each item is defined in our C<endpoints.json>
file.
Returns a L<URI> instance.
=head2 is_rate_limited
Returns true if we are currently rate
ile::Basename;
use Path::Tiny;
use Net::Async::HTTP;
use HTTP::Request::Common;
use JSON::MaybeUTF8 qw(:v1);
use JSON::MaybeXS;
use File::ShareDir;
use URI::Escape qw(uri_escape_utf8);
use Scalar::Ut
);
use constant SUPPORTED_COUNTRIES_URL => 'https://documentation.onfido.com/identityISOsupported.json';
# Mapping file extension to mime type for currently
# supported document types
my %FILE_MIME_T
try {
my ($res) = @_;
my $data = decode_json_utf8($res->content);
$log->tracef('Have response %s', $data);
s;
use Clone 'clone';
use Date::Utility;
use Data::UUID;
use File::Basename;
use Path::Tiny;
use JSON::MaybeUTF8 qw(:v1);
use MIME::Base64;
# New HTTP server implementation
use Net::Async::HTTP::Ser
'/v3.4/applicants' => sub {
my $req = shift;
my $data = decode_json_utf8($req->body);
my $id = Data::UUID->new->create_str();
my $appl
>{$k} = $data->{$k};
}
$applicants{$id} = $applicant;
return json_response($req, $applicant);
},
'/v3.4/documents' => sub {
my $req
STRACT: JsonApi helpers for Dancer2 apps
use 5.38.0;
package Dancer2::Plugin::JsonApi;
our $AUTHORITY = 'cpan:YANICK';
$Dancer2::Plugin::JsonApi::VERSION = '0.0.1';
use Dancer2::Plugin::JsonApi::Reg
ncer2::Serializer::JsonApi;
has registry => (
plugin_keyword => 'jsonapi_registry',
is => 'ro',
default => sub ($self) {
Dancer2::Plugin::JsonApi::Registry->new
( app => $self->app );
}
);
sub jsonapi : PluginKeyword ( $plugin, $type, $sub ) {
return sub {
my $result = $sub->();
return [
$type => $result,
{
use 5.32.0;
package Dancer2::Plugin::JsonApi::Schema;
our $AUTHORITY = 'cpan:YANICK';
$Dancer2::Plugin::JsonApi::Schema::VERSION = '0.0.1';
use Moo;
use experimental qw/ signatures /;
use List::Al
'ro' );
sub serialize ( $self, $data, $extra_data = {} ) {
my $serial = {};
$serial->{jsonapi} = { version => '1.0' };
my @included;
if ( defined $data ) {
$serial->{data
8
=head1 NAME
Dancer2::Plugin::JsonApi::Schema
=head1 VERSION
version 0.0.1
=head1 DESCRIPTION
Defines a type of object to serialize/deserialize from/to the
JSON:API format.
=head1 ATTRIBUTES
on Demand broadcasts for offline viewing
use Carp qw( croak );
use HTTP::Tiny ();
use JSON::PP qw( decode_json );
use Video::NRK::Cache::ProgramId;
use Video::NRK::Cache::Ytdlp;
my $version = $Vi
s,
);
}
method get_json ($endpoint) {
my $json_url = "$psapi_base$endpoint" =~ s/\{id\}/$program_id/r;
my $res = $ua->get($json_url, {headers => { Accept => 'application/json' }});
my $error = $
de_json $res->{content};
}
method get_metadata () {
my $json = $self->get_json("/playback/metadata/program/{id}");
my $title = $json->{preplay}{titles}{title} // '';
if (my $subtitle = $json->{
organizational
use v5.14;
use Moo;
extends qw/ SemanticWeb::Schema::Organization /;
use MooX::JSON_LD 'FundingScheme';
use Ref::Util qw/ is_plain_hashref /;
# RECOMMEND PREREQ: Ref::Util::XS
use
$formats = [qw(
text text-simple text-pretty
json json-pretty yaml perl
ruby phpserialization)];
if (!$self->{default_p
=> $formats],
};
$copts->{json} = {
$_t->('json'),
summary => N__("Equivalent to --format=json-pretty"),
};
$copts->{nak
ed_res} = {
$_t->('naked_res'),
summary => N__("When outputing as JSON, strip result envelope"),
};
$copts->{format_options} = {
schools.
use v5.14;
use Moo;
extends qw/ SemanticWeb::Schema::AdministrativeArea /;
use MooX::JSON_LD 'SchoolDistrict';
use Ref::Util qw/ is_plain_hashref /;
# RECOMMEND PREREQ: Ref::Util::XS
use
best practices.
use v5.14;
use Moo;
extends qw/ SemanticWeb::Schema::Intangible /;
use MooX::JSON_LD 'GeospatialGeometry';
use Ref::Util qw/ is_plain_hashref /;
# RECOMMEND PREREQ: Ref::Util::XS
edicate => '_has_geo_contains',
json_ld => 'geoContains',
);
has geo_covered_by => (
is => 'rw',
predicate => '_has_geo_covered_by',
json_ld => 'geoCoveredBy',
);
has
predicate => '_has_geo_covers',
json_ld => 'geoCovers',
);
has geo_crosses => (
is => 'rw',
predicate => '_has_geo_crosses',
json_ld => 'geoCrosses',
);
has geo_di
or online.
use v5.14;
use Moo;
extends qw/ SemanticWeb::Schema::BroadcastService /;
use MooX::JSON_LD 'RadioBroadcastService';
use Ref::Util qw/ is_plain_hashref /;
# RECOMMEND PREREQ: Ref::Util::
h machine.
use v5.14;
use Moo;
extends qw/ SemanticWeb::Schema::FinancialService /;
use MooX::JSON_LD 'AutomatedTeller';
use Ref::Util qw/ is_plain_hashref /;
# RECOMMEND PREREQ: Ref::Util::XS
us
consumes energy
use v5.14;
use Moo;
extends qw/ SemanticWeb::Schema::Intangible /;
use MooX::JSON_LD 'EnergyConsumptionDetails';
use Ref::Util qw/ is_plain_hashref /;
# RECOMMEND PREREQ: Ref::Uti
scale_max',
json_ld => 'energyEfficiencyScaleMax',
);
has energy_efficiency_scale_min => (
is => 'rw',
predicate => '_has_energy_efficiency_scale_min',
json_ld => 'energy
_category => (
is => 'rw',
predicate => '_has_has_energy_efficiency_category',
json_ld => 'hasEnergyEfficiencyCategory',
);
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
S
age facility.
use v5.14;
use Moo;
extends qw/ SemanticWeb::Schema::LocalBusiness /;
use MooX::JSON_LD 'SelfStorage';
use Ref::Util qw/ is_plain_hashref /;
# RECOMMEND PREREQ: Ref::Util::XS
use na