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::XS-"new()>> as "<$json-"$key($value)>>.
35
36   default_json
37       Returns "<JSON::XS-"new()>> with:
38
39               'utf8'            => 1,
40               'pretty'          => 1,
41               'convert_blessed' => 1,
42
43   json
44       Returns current JSON::XS 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 then the result is
52       written 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
61       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=JSON-Util>.  I will be
62       notified, and then you'll automatically be notified of progress on your
63       bug as I make changes.
64

SUPPORT

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

ACKNOWLEDGEMENTS

94       Copyright 2009 Jozef Kutej, all rights reserved.
95
96       This program is free software; you can redistribute it and/or modify it
97       under the same terms as Perl itself.
98
99
100
101perl v5.12.3                      2011-03-20                     JSON::Util(3)
Impressum