use strict; use warnings; use JSON::PP; my $json = { 'book' => { 'title' => JSON::PP::true, 'pages' => 5.03 #this number } }; open my $fh, '>', 'data_out.json'; print $fh encode_json($json); #this line is in error close $fh;