diff --git a/README.md b/README.md index 7c58aa0..4f0a2d8 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ REQUIREMENTS: - Perl 5.014 or later (you need the IO::Socket::SSL perl library for ssl-support, - JSON::Any perl library for JSON support and + JSON::PP perl library for JSON support and IO::Socket:INET6 perl library for ipv6-support) - Linux or probably any common Unix system diff --git a/ddclient b/ddclient index 3ff2972..6053c1c 100755 --- a/ddclient +++ b/ddclient @@ -1949,13 +1949,13 @@ EOM ## load_json_support ###################################################################### sub load_json_support { - my $json_loaded = eval {require JSON::Any}; + my $json_loaded = eval {require JSON::PP}; unless ($json_loaded) { 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 } - import JSON::Any; + import JSON::PP (qw/decode_json/); } ###################################################################### ## geturl @@ -4273,9 +4273,9 @@ sub nic_cloudflare_update { # Strip header $reply =~ s/^.*?\n\n//s; - my $response = JSON::Any->jsonToObj($reply); - if ($response->{result} eq 'error') { - failed ("%s", $response->{msg}); + my $response = eval {decode_json($reply)}; + if (!defined $response || !defined $response->{result}) { + failed ("invalid json or result."); next; } @@ -4300,9 +4300,9 @@ sub nic_cloudflare_update { # Strip header $reply =~ s/^.*?\n\n//s; - $response = JSON::Any->jsonToObj($reply); - if ($response->{result} eq 'error') { - failed ("%s", $response->{msg}); + $response = eval {decode_json($reply)}; + if (!defined $response || !defined $response->{result}) { + failed ("invalid json or result."); next; } @@ -4326,9 +4326,9 @@ sub nic_cloudflare_update { # Strip header $reply =~ s/^.*?\n\n//s; - $response = JSON::Any->jsonToObj($reply); - if ($response->{result} eq 'error') { - failed ("%s", $response->{msg}); + $response = eval {decode_json($reply)}; + if (!defined $response || !defined $response->{result}) { + failed ("invalid json or result."); } else { success ("%s -- Updated Successfully to %s", $domain, $ip);