eg/json_output.pl

filter: Statementstmt 100% 11 / 11 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 14 / 14 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« eg/html_table.pl ↑ Summary eg/skip_and_sort.pl »
1 #!/usr/bin/env perl
2 1 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Text::Stencil;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # use {{ literal escape for JSON braces
7 1 my $s = Text::Stencil->new(
8 header => '[',
9 row => '{{"id":{0:int},"name":"{1:json}","active":{2:bool:true:false}}',
10 footer => ']',
11 separator => ',',
12 );
13  
14 1 my @rows = (
15 [1, 'Alice "A"', 1],
16 [2, "Bob\nSmith", 0],
17 [3, 'Charlie', 1],
18 );
19  
20 1 say $s->render(\@rows);
« eg/html_table.pl ↑ Summary eg/skip_and_sort.pl »