in reply to How can I convert this raw data to a hash?

If the simplicity of this JSON string is guaranteed, you can try the following very crude (Module free) JSON to perl converter,
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...>
Output:
The ID for Science Fiction is:878
NOT RECOMMENDED for production code.

                "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
    NOT RECOMMENDED

    I feel like this should be at the top of the node.

    But if you're going down that route, then this classic node is worth pointing out: JSON parser as a single Perl Regex, which works on the data in the root node when you apply fanasy's fix from here. Update: To be clear, I'm not seriously suggesting this as a solution here :-)

Re^2: How can I convert this raw data to a hash?
by GrandFather (Saint) on Dec 21, 2020 at 22:20 UTC

    If JSON::PP is in core, why avoid it and suggest code with a caveat that it shouldn't be used due to badness?

    Update Correct JSON to JSON::PP - thanks Haarg

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
      Some potential excuses:

      • Older perl, missing core JSON
      • Too scared/lazy/ignorant to use JSON
      • Because you can

                      "Imaginary friends are a sign of a mental disorder if they cause distress, including antisocial behavior. Religion frequently meets that description"

        Only "Older perl, missing core JSON " is a real justification, and then only of the OP provides a good reason for not being able to use a newer Perl. Part of our job, as I see it anyway, is to help people overcome scared/ignorant and encourage the right kind of laziness.

        Anything else just looks like XP whoring. :-D

        Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond