in reply to Re: Perplexing JSON decoding issue.
in thread Perplexing JSON decoding issue.

Hi Miyako,

I also noticed that it worked as $apiJson[0]->[0]->{'id'}; Not entirely sure what makes that different

Compare these two:

my @apiJson = decode_json( $apiContent ); my $msgID = $apiJson[0]->[0]{id}; # or # my $apiJson = decode_json( $apiContent ); my $msgID = $apiJson->[0]{id};

In the first, you're taking the return value of decode_json, which I believe is just a single value, an arrayref or hashref, storing it in an array @apiJson which now just has a single element, and accessing that element with $apiJson[0]. In the second version, you're taking that single return value and storing it in the scalar $apiJson directly. (As far as I can tell decode_json behaves the same in list and array context.)

Hope this helps,
-- Hauke D