Iam trying to create a simple array KEY => VALUE from a json response, here's my results when I dump the array but the keys are not what Im excpecting:
$VAR1 = 'expectedvalue1';
$VAR2 = 'expectedvalue2';
$VAR3 = 'expectedvalue3';
and here's my code that I found some part of it here (some comments says that there's backslash missing)
my %result = ();
foreach my $row (@json_response){
$result{ $row->{"json_key"} } = $row->{"json_value"};
}
print Dumper(%result);
While I'm trying to get
expectedkey1 = expectedvalue1
expectedkey2 = expectedvalue2
expectedkey3 = expectedvalue3
Edit : I made a mistake in the names of keys.
Dumper, so you get this$VAR1stuff. Runprint Dumper \%resultto pass a reference to Data::Dumper, and you'll see something like$VAR1 = { "foo" => "bar", ... }. But that doesn't explain why your output doesn't have the keys as variables. Please edit and include the JSON you are parsing, and how.print Dumper \%resultit showed the expected result O.o well post your answer I'll accept it.. thank you