This statement is wrong:
print Dumper($decoded->{'result'}['manager']);
Because you do not have warnings turned on, which is a very bad thing, you do not get the error
Argument "manager" isn't numeric in array element at ...
You are using square brackets [ .. ] which means Perl expects what is inside it to be an array index, a number. You put a string. Perl will automatically try to cast the string to a number, but will warn you about it. Unless you foolishly have warnings turned off. Any string that does not begin with a number is cast to 0, so it will try and access array element 0, like this:
print Dumper($decoded->{'result'}[0]);
Which is exactly what you see in the Dumper output:
$VAR1 = {
'manager' => {
'value' => 'testvalue',
'data' => 'testdata'
}
};
What you need to do is to get the value from the key 'value' inside the hash value for key 'manager', inside the first array element of the hash stored in the key 'result':
print $decoded->{'result'}[0]{'manager'}{'value'}
You can easily traverse the json structure to see the Perl structure, which looks similar.
{ # hash
"result": [ # key "result", stores array [
{ # hash
"manager": { # key "manager", stores hash {
"value": "testvalue", # key "value", value "testvalue"
"data": "testdata" # key "data", value "testdata"
}
}
]
}
Always put this in your Perl code:
use strict;
use warnings;
To avoid making simple mistakes or hide critical errors.
print $decoded->{result}[0]{manager}{value}