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
18           # Dump into a pre-existing buffer
19           my $json;
20           JSON::Syck::DumpInto(\$json, $data);
21

DESCRIPTION

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

DIFFERENCE WITH JSON

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

REFERENCES

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

UTF-8 FLAGS

61       By default this module doesn't touch any of utf-8 flags set in strings,
62       and assumes UTF-8 bytes to be passed and emit.
63
64       However, when you set $JSON::Syck::ImplicitUnicode to 1, this module
65       properly decodes UTF-8 binaries and sets UTF-8 flag everywhere, as in:
66
67         JSON (UTF-8 bytes)   => Perl (UTF-8 flagged)
68         JSON (UTF-8 flagged) => Perl (UTF-8 flagged)
69         Perl (UTF-8 bytes)   => JSON (UTF-8 flagged)
70         Perl (UTF-8 flagged) => JSON (UTF-8 flagged)
71
72       By default, JSON::Syck::Dump will only transverse up to 512 levels of a
73       datastructure in order to avoid an infinite loop when it is presented
74       with an circular reference.
75
76       However, you set $JSON::Syck::MaxLevels to a larger value if you have
77       very complex structures.
78
79       Unfortunately, there's no implicit way to dump Perl UTF-8 flagged data
80       structure to utf-8 encoded JSON. To do this, simply use Encode module,
81       e.g.:
82
83         use Encode;
84         use JSON::Syck qw(Dump);
85
86         my $json = encode_utf8( Dump($data) );
87
88       Alternatively you can use Encode::JavaScript::UCS to encode Unicode
89       strings as in %uXXXX form.
90
91         use Encode;
92         use Encode::JavaScript::UCS;
93         use JSON::Syck qw(Dump);
94
95         my $json_unicode_escaped = encode( 'JavaScript-UCS', Dump($data) );
96

QUOTING

98       According to the JSON specification, all JSON strings are to be double-
99       quoted.  However, when embedding JavaScript in HTML attributes, it may
100       be more convenient to use single quotes.
101
102       Set $JSON::Syck::SingleQuote to 1 will make both "Dump" and "Load"
103       expect single-quoted string literals.
104

BUGS

106       Dumping into tied (or other magic variables) with "DumpInto" might not
107       work properly in all cases.
108
109       When dumping with "DumpFile", some spacing might be wrong and
110       $JSON::Syck::SingleQuote might be handled incorrectly.
111

SEE ALSO

113       JSON::XS, YAML::Syck
114

AUTHORS

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