I'm trying to create an api using perl, the api is for a react native, when the user submits a form on the app I'll get the following object, I'm new to perl and I'm lost trying to loop thro the object :/
{
checkboxes: [
{
id: "1",
fullname: "Name 1",
color: "red",
res: false
},
{
color: "green",
fullname: "Name 2",
id: "2",
res: false
},
{
color: "blue",
id: "3",
fullname: "Name 3",
res: false
}
]
}
my $data_decoded = decode_json($data);
I'm trying this loop, but it only prints the full object.
foreach $a (@data) {
print "value of a: $a\n";
}
for (@{ $data->checkboxes })?$You mean for (@{ $data_decoded->checkboxes })(I would have named$data$json. It makes no sense to use_decodedeverywhere.)for my $checkbox (@{ $data_decoded->checkboxes }) { print "Color: ", $checkbox->{color}, "\n"; }