se JSON;
use Data::Dumper;
Getopt::Compact::WithCmd->add_type(JSON => Str => sub { decode_json(shift) });
my $go = Getopt::Compact::WithCmd->new(
global_struct => {
from_json =>
{
type => 'JSON',
},
},
);
my $data = $go->opts->{from_json};
print Dumper $data;
# will run cmd:
$ ./add_type.pl --from_json '{"foo":"bar"}'
$VAR1 = {