File: Whitespace.pod

package info (click to toggle)
libjson-parse-perl 0.62-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 572 kB
  • sloc: ansic: 3,614; perl: 475; makefile: 12
file content (89 lines) | stat: -rw-r--r-- 2,056 bytes parent folder | download
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

=encoding UTF-8

=head1 NAME

JSON::Whitespace - Alter the insignificant whitespace of JSON

=head1 SYNOPSIS

    use JSON::Whitespace ':all';
    
    my $in = <<EOF;
    {
                "animals":{
                        "kingkong":"🦍"
                },
                "baka":[
                        "ドジ"
                ],
                "fruit":{
                        "grape":"🍇"
                },
                "moons":{
                        "🌑":0
                }
        }
    EOF
    my $minify = json_minify ($in);
    print $minify;


This outputs

    {"animals":{"kingkong":"🦍"},"baka":["ドジ"],"fruit":{"grape":"🍇"},"moons":{"🌑":0}}

=head1 VERSION

This documents version 0.62 of JSON::Whitespace corresponding to
L<git commit d04630086f6c92fea720cba4568faa0cbbdde5a6|https://github.com/benkasminbullock/JSON-Parse/commit/d04630086f6c92fea720cba4568faa0cbbdde5a6> released on Sat Jul 16 08:23:13 2022 +0900.



=head1 DESCRIPTION

This module offers functions to manipulate the "insignificant
whitespace" part of a JSON string (the whitespace which is not inside
strings). According to L<the JSON specification|JSON::Parse/SEE ALSO>
"insignificant whitespace" consists of space (C<%x20>), horizontal tab
(C<%x09>), line feed or new line (C<%x0A>) and carriage return
(C<%x0D>).

=head1 FUNCTIONS

=head2 json_indent

    my $indented = json_indent ($json);

Add indentation to C<$json>.

=head2 json_minify

    my $minified = json_minify ($json);

Remove all whitespace, including trailing newlines, from C<$json>.

=head1 SEE ALSO

Documentation about JSON is in L<JSON::Parse>. JSON::Whitespace is
based on L<JSON::Tokenize>, which breaks JSON into tokens without
putting it into Perl structures.



=head1 AUTHOR

Ben Bullock, <bkb@cpan.org>

=head1 COPYRIGHT & LICENCE

This package and associated files are copyright (C) 
2016-2022
Ben Bullock.

You can use, copy, modify and redistribute this package and associated
files under the Perl Artistic Licence or the GNU General Public
Licence.