The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

use strict;
use feature 'say';
BEGIN {
package My::Types;
use Type::Library 1.012
-utils,
-extends => [ 'Types::Standard' ],
-declare => 'JSONCapable';
declare JSONCapable,
as Undef
| ScalarRef[ Enum[ 0..1 ] ]
| Num
| Str
| ArrayRef[ JSONCapable ]
| HashRef[ JSONCapable ]
;
}
use My::Types 'is_JSONCapable';
my $var = {
foo => 1,
bar => [ \0, "baz", [] ],
};
say is_JSONCapable $var;