in reply to How can I convert this raw data to a hash?
Output:use strict; use warnings; (my $datastring=do{local $/=undef; <DATA>}) =~s/:/=>/g; my $data = eval $datastring; my %by_name = map { $_->{name} => $_->{id} } @{$data->{'genres'}}; print "The ID for Science Fiction is:", $by_name{"Science Fiction"} , +"\n"; __DATA__ <<<YOUR JSON Here...>
NOT RECOMMENDED for production code.The ID for Science Fiction is:878
"Imaginary friends are a sign of a mental disorder if they cause distress, including antisocial behavior. Religion frequently meets that description"
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How can I convert this raw data to a hash?
by haukex (Archbishop) on Dec 22, 2020 at 07:53 UTC | |
Re^2: How can I convert this raw data to a hash?
by GrandFather (Saint) on Dec 21, 2020 at 22:20 UTC | |
by Haarg (Priest) on Dec 22, 2020 at 06:39 UTC | |
by NetWallah (Canon) on Dec 21, 2020 at 22:31 UTC | |
by GrandFather (Saint) on Dec 21, 2020 at 22:40 UTC |