Use JSON::PP instead of the (deprecated) JSON::Any

This commit is contained in:
Lonnie Abelbeck 2017-01-20 15:05:25 -06:00 committed by wimpunk
parent 47df8f45b4
commit fca9b2149b

View file

@ -1949,13 +1949,13 @@ EOM
## load_json_support ## load_json_support
###################################################################### ######################################################################
sub load_json_support { sub load_json_support {
my $json_loaded = eval {require JSON::Any}; my $json_loaded = eval {require JSON::PP};
unless ($json_loaded) { unless ($json_loaded) {
fatal(<<"EOM"); fatal(<<"EOM");
Error loading the Perl module JSON::Any needed for cloudflare update. Error loading the Perl module JSON::PP needed for cloudflare update.
EOM EOM
} }
import JSON::Any; import JSON::PP (qw/decode_json/);
} }
###################################################################### ######################################################################
## geturl ## geturl
@ -4273,9 +4273,9 @@ sub nic_cloudflare_update {
# Strip header # Strip header
$reply =~ s/^.*?\n\n//s; $reply =~ s/^.*?\n\n//s;
my $response = JSON::Any->jsonToObj($reply); my $response = eval {decode_json($reply)};
if ($response->{result} eq 'error') { if (!defined $response || !defined $response->{result}) {
failed ("%s", $response->{msg}); failed ("invalid json or result.");
next; next;
} }
@ -4300,9 +4300,9 @@ sub nic_cloudflare_update {
# Strip header # Strip header
$reply =~ s/^.*?\n\n//s; $reply =~ s/^.*?\n\n//s;
$response = JSON::Any->jsonToObj($reply); $response = eval {decode_json($reply)};
if ($response->{result} eq 'error') { if (!defined $response || !defined $response->{result}) {
failed ("%s", $response->{msg}); failed ("invalid json or result.");
next; next;
} }
@ -4326,9 +4326,9 @@ sub nic_cloudflare_update {
# Strip header # Strip header
$reply =~ s/^.*?\n\n//s; $reply =~ s/^.*?\n\n//s;
$response = JSON::Any->jsonToObj($reply); $response = eval {decode_json($reply)};
if ($response->{result} eq 'error') { if (!defined $response || !defined $response->{result}) {
failed ("%s", $response->{msg}); failed ("invalid json or result.");
} else { } else {
success ("%s -- Updated Successfully to %s", $domain, $ip); success ("%s -- Updated Successfully to %s", $domain, $ip);