File: jsoncapable.pl

package info (click to toggle)
libtype-tiny-perl 2.002001-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,948 kB
  • sloc: perl: 14,610; makefile: 2; sh: 1
file content (29 lines) | stat: -rw-r--r-- 435 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use strict;
use warnings;
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;