I am generating a Json string, which isn't generating good Json. To me it looks good, but I have a mistake somwhere. I can't find where it is and how to remove it. Here is the entire source (since it is very short).
use strict;
use warnings;
use JSON qw( decode_json );
sub getJsonStr{
print "Enter the name of the person: ";
my $name = <>;
print "Enter the age of the person: ";
my $age = <>;
my $json = '{
"name" :"'.$name.'",
"age" :"'.$age.'"
}';
}
my $jsonStr = getJsonStr();
print $jsonStr;
my $jobj = decode_json($jsonStr);
'{"name" :"'.$name.'" ...'better written asq({"name" :"$name" ...)qq({"name": "$name", ...})in order for$nameto interpolate (not justq(…)).