1JSON::Util(3)         User Contributed Perl Documentation        JSON::Util(3)
2
3
4

NAME

6       JSON::Util - easy and portable encode/decode of JSON
7

SYNOPSIS

9           use JSON::Util;
10           $data = JSON::Util->decode('{"bar": "foo"}');
11           $data = JSON::Util->decode('some.json');
12           JSON::Util->encode({ 'foo' => 'bar' }, 'someother.json');
13
14           $data = JSON::Util->decode(['..', 'folder', some.json]);
15           JSON::Util->encode([123,321], ['..', 'folder', someother.json]);
16
17           print JSON::Util->encode([987,789]), "\n";
18           print JSON::Util->encode({987 => 789}), "\n";
19
20           my $json = JSON::Util->new(pretty => 0, convert_blessed => 1);
21           print $json->encode([ $object, $object2 ]);
22
23           # with file locking
24           $data = JSON::Util->decode(['..', 'folder', some.json], { 'LOCK_SH' => 1 });
25           $data = JSON::Util->decode(['..', 'folder', some.json], { 'LOCK_SH' => 1, LOCK_NB => 1 });
26           JSON::Util->encode([123,321], ['..', 'folder', someother.json], { 'LOCK_EX' => 1 });
27           JSON::Util->encode([123,321], ['..', 'folder', someother.json], { 'LOCK_EX' => 1, LOCK_NB => 1 });
28

DESCRIPTION

METHODS

31   new()
32       Object constructor. Needed only when the "default_json" configuration
33       needs to be changed. Any key/value passed as parameter will be called
34       on "<JSON::MaybeXS-"new()>> as "<$json-"$key($value)>>.
35
36   default_json
37       Returns "<JSON::MaybeXS-"new()>> with:
38
39               'utf8'            => 1,
40               'pretty'          => 1,
41               'convert_blessed' => 1,
42
43   json
44       Returns current JSON::MaybeXS object.
45
46   decode($what, [$opt])
47       Return ref with decoded $what. See IO::Any for $where and $opt
48       description.
49
50   encode($data, [$where], [$opt])
51       Returns encoded $data. If $where is passed then the result is written
52       there. See IO::Any for $where and $opt description.
53

AUTHOR

55       Jozef Kutej, "<jkutej at cpan.org>"
56

BUGS

58       Please report any bugs or feature requests to "bug-json-util at
59       rt.cpan.org", or through the web interface at
60       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=JSON-Util>.  I will be
61       notified, and then you'll automatically be notified of progress on your
62       bug as I make changes.
63

SUPPORT

65       You can find documentation for this module with the perldoc command.
66
67           perldoc JSON::Util
68
69       You can also look for information at:
70
71       ·   RT: CPAN's request tracker
72
73           <http://rt.cpan.org/NoAuth/Bugs.html?Dist=JSON-Util>
74
75       ·   AnnoCPAN: Annotated CPAN documentation
76
77           <http://annocpan.org/dist/JSON-Util>
78
79       ·   CPAN Ratings
80
81           <http://cpanratings.perl.org/d/JSON-Util>
82
83       ·   Search CPAN
84
85           <http://search.cpan.org/dist/JSON-Util>
86

ACKNOWLEDGEMENTS

88       The following people have contributed to the Sys::Path by committing
89       their code, sending patches, reporting bugs, asking questions,
90       suggesting useful advises, nitpicking, chatting on IRC or commenting on
91       my blog (in no particular order):
92
93           John SJ Anderson
94
96       Copyright 2009 Jozef Kutej, all rights reserved.
97
98       This program is free software; you can redistribute it and/or modify it
99       under the same terms as Perl itself.
100
101
102
103perl v5.32.0                      2020-07-28                     JSON::Util(3)
Impressum