You could start by checking the MIME type:
#!/usr/bin/env perl use strict; use warnings; use LWP::UserAgent; my $ua = LWP::UserAgent->new; my @urls = ( 'https://jsonplaceholder.typicode.com/todos/1', 'https://www.perl.org/' ); for my $url (@urls) { my $res = $ua->get ($url); print index($res->header('Content-Type'), 'application/json') > -1 + ? "$url is JSON\n" : "$url is not JSON\n"; }
🦛
In reply to Re^3: File::Fetch fetch to scalar
by hippo
in thread File::Fetch fetch to scalar
by vinoth.ree
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |