1JSON::Whitespace(3) User Contributed Perl Documentation JSON::Whitespace(3)
2
3
4
6 JSON::Whitespace - Alter the insignificant whitespace of JSON
7
9 use JSON::Whitespace ':all';
10
11 my $in = <<EOF;
12 {
13 "animals":{
14 "kingkong":"🦍"
15 },
16 "baka":[
17 "ドジ"
18 ],
19 "fruit":{
20 "grape":"🍇"
21 },
22 "moons":{
23 "🌑":0
24 }
25 }
26 EOF
27 my $minify = json_minify ($in);
28 print $minify;
29
30 This outputs
31
32 {"animals":{"kingkong":"🦍"},"baka":["ドジ"],"fruit":{"grape":"🍇"},"moons":{"🌑":0}}
33
35 This documents version 0.61 of JSON::Whitespace corresponding to git
36 commit 033269fa8972fdce8626aa65cd11a5394ab50492
37 <https://github.com/benkasminbullock/JSON-
38 Parse/commit/033269fa8972fdce8626aa65cd11a5394ab50492> released on Thu
39 Feb 11 09:14:04 2021 +0900.
40
42 This module offers functions to manipulate the "insignificant
43 whitespace" part of a JSON string (the whitespace which is not inside
44 strings). According to the JSON specification "insignificant
45 whitespace" consists of space (%x20), horizontal tab (%x09), line feed
46 or new line (%x0A) and carriage return (%x0D).
47
49 json_indent
50 my $indented = json_indent ($json);
51
52 Add indentation to $json.
53
54 json_minify
55 my $minified = json_minify ($json);
56
57 Remove all whitespace, including trailing newlines, from $json.
58
60 Documentation about JSON is in JSON::Parse. JSON::Whitespace is based
61 on JSON::Tokenize, which breaks JSON into tokens without putting it
62 into Perl structures.
63
65 Ben Bullock, <bkb@cpan.org>
66
68 This package and associated files are copyright (C) 2016-2021 Ben
69 Bullock.
70
71 You can use, copy, modify and redistribute this package and associated
72 files under the Perl Artistic Licence or the GNU General Public
73 Licence.
74
75
76
77perl v5.34.0 2021-07-22 JSON::Whitespace(3)