Quiq/Json.pm

filter: Statementstmt 79.1% 19 / 24 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 100% 1 / 1 totaltotal 76.4% 26 / 34 CC 2 SCAR 8.1
CC
2
Cov
73%
pretty
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
« Quiq/MailTo.pm ↑ Summary Quiq/Database/Patch.pm »
1 # -----------------------------------------------------------------------------
2  
3 =encoding utf8
4  
5 =head1 NAME
6  
7 Quiq::Json - Operationen auf JSON Code
8  
9 =head1 BASE CLASS
10  
11 L<Quiq::Object>
12  
13 =cut
14  
15 # -----------------------------------------------------------------------------
16  
17 package Quiq::Json;
18 1 ▶use base qw/Quiq::Object/;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 our $VERSION = '1.240';
25  
26 1 ▶use Quiq::Path;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶use JSON ();
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 # -----------------------------------------------------------------------------
30  
31 =head1 METHODS
32  
33 =head2 Klassenmethoden
34  
35 =head3 pretty() - Verschönere JSON Code
36  
37 =head4 Synopsis
38  
39 $json = $class->pretty($file);
40 $json = $class->pretty($jsonIn);
41  
42 =head4 Arguments
43  
44 =over 4
45  
46 =item $file
47  
48 (String) Datei mit JSON Code, der verschönert werden soll
49  
50 =item $jsonIn
51  
52 (String) JSON Code, der verschönert werden soll
53  
54 =back
55  
56 =head4 Returns
57  
58 (String) Verschönerter JSON Code
59  
60 =head4 Description
61  
62 Verschönere den JSON Code $jsonIn und liefere de resultierenden JSON Code
63 zurück.
64  
65 Enthält der Parameter der Methode weder Doppelpunkt (:) noch geschweifte
66 Klammer auf ({}, wird er als Dateiname angesehen.
67  
68 =cut
69  
70 # -----------------------------------------------------------------------------
71  
72 0 ▶sub pretty {
Subroutine pretty: not called CC=2 SCAR=17.9
Pod documented
73 0 my $class = shift;
74  
75 0 ▶ my $json = $_[0] =~ /[{:]/? shift:
Branch: 1 branch
BranchTrueFalseTotal
$_[0] =~ /[{:]/ ? : 0 0 0
76 Quiq::Path->read(shift,-decode=>'utf-8');
77  
78 0 my $j = JSON->new->allow_nonref;
79 0 my $h = $j->decode($json);
80  
81 0 return $j->pretty->encode($h);
82 }
83  
84 # -----------------------------------------------------------------------------
85  
86 =head1 VERSION
87  
88 1.240
89  
90 =head1 AUTHOR
91  
92 Frank Seitz, L<http://fseitz.de/>
93  
94 =head1 COPYRIGHT
95  
96 Copyright (C) 2026 Frank Seitz
97  
98 =head1 LICENSE
99  
100 This code is free software; you can redistribute it and/or modify
101 it under the same terms as Perl itself.
102  
103 =cut
104  
105 # -----------------------------------------------------------------------------
106  
107 1 1;
108  
109 # eof
« Quiq/MailTo.pm ↑ Summary Quiq/Database/Patch.pm »