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

NAME

6       JSON::Syck - JSON is YAML (but consider using JSON::XS instead!)
7

SYNOPSIS

9           use JSON::Syck; # no exports by default
10
11           my $data = JSON::Syck::Load($json);
12           my $json = JSON::Syck::Dump($data);
13
14           # $file can be an IO object, or a filename
15           my $data = JSON::Syck::LoadFile($file);
16           JSON::Syck::DumpFile($file, $data);
17

DESCRIPTION

19       JSON::Syck is a syck implementation of JSON parsing and generation.
20       Because JSON is YAML
21       (<http://redhanded.hobix.com/inspect/yamlIsJson.html>), using syck
22       gives you a fast and memory-efficient parser and dumper for JSON data
23       representation.
24
25       However, a newer module JSON::XS, has since emerged.  It is more
26       flexible, efficient and robust, so please consider using it instead of
27       this module.
28

DIFFERENCE WITH JSON

30       You might want to know the difference between the JSON module and this
31       one.
32
33       Since JSON is a pure-perl module and JSON::Syck is based on libsyck,
34       JSON::Syck is supposed to be very fast and memory efficient. See
35       chansen's benchmark table at
36       <http://idisk.mac.com/christian.hansen/Public/perl/serialize.pl>
37
38       JSON.pm comes with dozens of ways to do the same thing and lots of
39       options, while JSON::Syck doesn't. There's only "Load" and "Dump".
40
41       Oh, and JSON::Syck doesn't use camelCase method names :-)
42

REFERENCES

44   SCALAR REFERENCE
45       For now, when you pass a scalar reference to JSON::Syck, it
46       dereferences to get the actual scalar value.
47
48       JSON::Syck raises an exception when you pass in circular references.
49
50       If you want to serialize self refernecing stuff, you should use YAML
51       which supports it.
52
53   SUBROUTINE REFERENCE
54       When you pass subroutine reference, JSON::Syck dumps it as null.
55

UTF-8 FLAGS

57       By default this module doesn't touch any of utf-8 flags set in strings,
58       and assumes UTF-8 bytes to be passed and emit.
59
60       However, when you set $JSON::Syck::ImplicitUnicode to 1, this module
61       properly decodes UTF-8 binaries and sets UTF-8 flag everywhere, as in:
62
63         JSON (UTF-8 bytes)   => Perl (UTF-8 flagged)
64         JSON (UTF-8 flagged) => Perl (UTF-8 flagged)
65         Perl (UTF-8 bytes)   => JSON (UTF-8 flagged)
66         Perl (UTF-8 flagged) => JSON (UTF-8 flagged)
67
68       Unfortunately, there's no implicit way to dump Perl UTF-8 flagged data
69       structure to utf-8 encoded JSON. To do this, simply use Encode module,
70       e.g.:
71
72         use Encode;
73         use JSON::Syck qw(Dump);
74
75         my $json = encode_utf8( Dump($data) );
76
77       Alternatively you can use Encode::JavaScript::UCS to encode Unicode
78       strings as in %uXXXX form.
79
80         use Encode;
81         use Encode::JavaScript::UCS;
82         use JSON::Syck qw(Dump);
83
84         my $json_unicode_escaped = encode( 'JavaScript-UCS', Dump($data) );
85

QUOTING

87       According to the JSON specification, all JSON strings are to be double-
88       quoted.  However, when embedding JavaScript in HTML attributes, it may
89       be more convenient to use single quotes.
90
91       Set $JSON::Syck::SingleQuote to 1 will make both "Dump" and "Load"
92       expect single-quoted string literals.
93

SEE ALSO

95       JSON::XS,
96

AUTHORS

98       Audrey Tang <cpan@audreyt.org>
99
100       Tatsuhiko Miyagawa <miyagawa@gmail.com>
101
103       Copyright 2005-2009 by Audrey Tang <cpan@audreyt.org>.
104
105       This software is released under the MIT license cited below.
106
107       The libsyck code bundled with this library is released by "why the
108       lucky stiff", under a BSD-style license.  See the COPYING file for
109       details.
110
111   The "MIT" License
112       Permission is hereby granted, free of charge, to any person obtaining a
113       copy of this software and associated documentation files (the
114       "Software"), to deal in the Software without restriction, including
115       without limitation the rights to use, copy, modify, merge, publish,
116       distribute, sublicense, and/or sell copies of the Software, and to
117       permit persons to whom the Software is furnished to do so, subject to
118       the following conditions:
119
120       The above copyright notice and this permission notice shall be included
121       in all copies or substantial portions of the Software.
122
123       THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
124       OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
125       MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
126       IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
127       CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
128       TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
129       SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
130
131
132
133perl v5.12.0                      2009-04-25                     JSON::Syck(3)
Impressum