0

I have a variable ($issue) that contains various values that I need to pull a single value (emailAddress) from. The contents of $issue (via Data::Dump) is:

'fields' => {
    'reporter' => {
        'name' => 'jeremywilson',
            'displayName' => 'Jeremy Wilson',
            'key' => '15429',
            'emailAddress' => '[email protected]',
            'timeZone' => 'America/New_York',
            'active' => bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' )
    },
    'customfield' => [
        {
            'active' => $VAR1->{'fields'}{'reporter'}{'active'},
            'timeZone' => 'America/New_York',
            'emailAddress' => '[email protected]',
            'key' => 'mexample',
            'name' => 'mexample',
            'displayName' => 'Mike Example'
        }
    ],
}

I get the first email via $issue->{fields}->{'reporter'}->{'emailAddress'} but how do I get the value from customfield?

3
  • 5
    $issue->{fields}->{customfield}[0]->{emailAddress}? A minimal reproducible example would help... Commented May 6, 2021 at 19:19
  • Yes, that works! Thanks. Commented May 6, 2021 at 19:25
  • Or you could use $issue->{fields}{customfield}[0]{emailAddress} to make record shorter. Commented May 7, 2021 at 0:08

1 Answer 1

1

The comments include two answers

$issue->{fields}->{customfield}[0]->{emailAddress}

and a shorter, but also correct

$issue->{fields}{customfield}[0]{emailAddress}

These answer the question that was asked, but likely, more clarification is needed for a general answer, for example, when there are more than one customfield, or if customfield is optional, how will the data be represented?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.