| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# This code is part of Perl distribution OODoc version 3.05. |
|
2
|
|
|
|
|
|
|
# The POD got stripped from this file by OODoc version 3.05. |
|
3
|
|
|
|
|
|
|
# For contributors see file ChangeLog. |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# This software is copyright (c) 2003-2025 by Mark Overmeer. |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
|
8
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
|
9
|
|
|
|
|
|
|
# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package OODoc::Export::JSON;{ |
|
13
|
|
|
|
|
|
|
our $VERSION = '3.05'; |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
1494
|
use parent 'OODoc::Export'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
11
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
89
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
27
|
|
|
19
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
78
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
7
|
use Log::Report 'oodoc'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
29
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
1423
|
use JSON (); |
|
|
1
|
|
|
|
|
12757
|
|
|
|
1
|
|
|
|
|
218
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#-------------------- |
|
26
|
|
|
|
|
|
|
|
|
27
|
0
|
|
|
0
|
1
|
|
sub new(%) { my $class = shift; $class->SUPER::new(serializer => 'json', @_) } |
|
|
0
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
#-------------------- |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Bleh: JSON has real true and false booleans :-( |
|
32
|
0
|
0
|
|
0
|
1
|
|
sub boolean($) { $_[1] ? $JSON::true : $JSON::false } |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub write($$%) |
|
36
|
0
|
|
|
0
|
1
|
|
{ my ($self, $output, $data, %args) = @_; |
|
37
|
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $fh; |
|
39
|
0
|
0
|
|
|
|
|
if($output eq '-') |
|
40
|
0
|
|
|
|
|
|
{ $fh = \*STDOUT; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
else |
|
43
|
0
|
0
|
|
|
|
|
{ open $fh, '>:encoding(UTF-8)', $output |
|
44
|
|
|
|
|
|
|
or fault __x"cannot write output to {file}", file => $output; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my $json = JSON->new->pretty($args{pretty_print}); |
|
48
|
0
|
|
|
|
|
|
$fh->print($json->encode($data)); |
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
0
|
0
|
|
|
|
$output eq '-' || $fh->close |
|
51
|
|
|
|
|
|
|
or fault __x"write errors to {file}", file => $output; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |