ackage Net::RDAP::JSON;
use JSON qw(-no_export);
use vars qw(@EXPORT $JSON);
use base qw(Exporter);
use strict;
@EXPORT = qw(encode_json decode_json to_json from_json);
$JSON = JSON->new->utf8->cano
code_json { $JSON->encode(@_) }
sub to_json { $JSON->encode(@_) }
sub decode_json { $JSON->decode(@_) }
sub from_json { $JSON->decode(@_) }
1;
__END__
=pod
=head1 NAME
L<Net::RDAP::JSON> -
a wrapper to allow JSON backends to be switched.
=head1 DESCRIPTION
This module is a wrapper around L<JSON>. It exists to make it easier to switch
the JSON module used by L<Net::RDAP>. You should no
::Property> will internally preserve the case of property and
value types so that JSON serialization via the C<TO_JSON()> method will return
the original data structure.
Please see the documentation
($_[1])} }
sub value_type { lc($_[0]->{value_type}) }
sub value { $_[0]->{value} }
sub TO_JSON {
my $self = shift;
return [
$self->type,
$self->params,
$self->
=cut
sub is_rdap { exists($_[0]->{'type'}) && $_[0]->{'type'} =~ /^application\/rdap/i }
sub TO_JSON {
my $self = shift;
my %hash = %{$self};
delete($hash{_document_url});
delete($h
P::Link> object with a C<rel> property of
C<related> and a C<type> property of C<application/rdap+json> (or C<undef>
if no subject object is found).
=cut
sub related {
my $self = shift;
for
ink ($self->links) {
if (q{related} eq $link->rel && $link->type =~ m/^application\/rdap\+json/) {
return $link;
}
}
return undef;
}
=head2 "Self" Link
$self
}
}
=pod
=head1 C<TO_JSON()>
C<Net::RDAP::Base> provides a C<TO_JSON()> so that any RDAP object can be
serialized back into JSON if your JSON serializer (L<JSON>, L<JSON::XS>, etc)
is configured
se JSON;
use POSIX qw(getpwuid);
use Net::RDAP::UA;
use Net::RDAP::Registry::IANARegistry;
use vars qw($UA $REGISTRY);
use constant {
IP4_URL => 'https://data.iana.org/rdap/ipv4.json',
https://data.iana.org/rdap/ipv6.json',
DNS_URL => 'https://data.iana.org/rdap/dns.json',
ASN_URL => 'https://data.iana.org/rdap/asn.json',
TAG_URL => 'h
ttps://data.iana.org/rdap/object-tags.json',
CACHE_TTL => 86400,
};
use strict;
our $UA;
our $REGISTRY = {};
=pod
=head1 NAME
L<Net::RDAP::Registry> - a module which provides an int
defined by
an IANA registry; see:
=over
=item * L<https://www.iana.org/assignments/rdap-json-values/rdap-json-values.xhtml>
=back
=cut
sub type { $_[0]->{'type'} }
=pod
=head2 Remark Descriptio
stant {
IANA_REGISTRY_URL => 'https://www.iana.org/assignments/rdap-json-values/rdap-json-values.xml',
RDAP_TYPE_NOTICE_OR_REMARK_TYPE => 'notice and remark type',
s> - a module which provides interface to the RDAP values
registry.
=head1 DESCRIPTION
The RDAP JSON Values Registry was defined in RFC 7483 and lists the
permitted values of certain RDAP object pro
defined by bn IANA registry; see:
=over
=item * L<https://www.iana.org/assignments/rdap-json-values/rdap-json-values.xhtml>
=back
=cut
sub status { $_[0]->{'status'} ? @{$_[0]->{'status'}} : () }
defined by an IANA registry, see:
=over
=item * L<https://www.iana.org/assignments/rdap-json-values/rdap-json-values.xhtml>
=back
=cut
sub action { $_[0]->{'eventAction'} }
=pod
=head2 Event Ac
ams->{$_[1]} }
sub value_type { $_[0]->{value_type} }
sub value { $_[0]->{value} }
sub TO_JSON {
my $self = shift;
return [
$self->type,
$self->params,
$self->
acementValue>.
=head2 JSON Path Expression Language
$lang = $field->pathLang;
Returns the JSON path expression language used, which is C<jsonpath> by default.
=head2 JSON Paths
$prePath =
{ shift->{'method'} || 'removal' }
sub pathLang { shift->{'pathLang'} || 'jsonpath' }
sub prePath { shift->{'prePath'} }
sub postPath { sh
Card::Address->new([$adr->type, $adr->params, $adr->value_type, $adr->value]) : undef);
}
sub TO_JSON { ['vcard', shift->{properties}] }
=pod
=head1 COPYRIGHT
Copyright 2018-2023 CentralNic Ltd, 2
s the role specified by C<$role>.
=over
=item * L<https://www.iana.org/assignments/rdap-json-values/rdap-json-values.xhtml>
=back
=cut
sub roles { $_[0]->{'roles'} ? @{$_[0]->{'roles'}} : () }
s
et::RDAP::Registry::IANARegistry->new($data);
C<$data> is a hashref corresponding to the decoded JSON representation
of the IANA registry.
=cut
sub new {
my ($package, $args, $url) = @_;
my
A qw(sha256_hex);
use File::Slurp;
use File::stat;
use File::Spec;
use HTTP::Request::Common;
use JSON;
use MIME::Base64;
use Net::ASN;
use Net::RDAP::Error;
use Net::RDAP::Help;
use Net::RDAP::Object
my $file = File::Spec->catfile(
File::Spec->tmpdir,
sprintf(
'%s-%s.json',
ref($self),
sha256_hex(join(chr(0), (
$VERSION,
}
my $response = $self->ua->mirror($url, $file, $ttl, $lang);
my $data = eval { decode_json(scalar(read_file($file))) };
if ($response->code >= 400) {
return $self->error_from_