ADC Home > Reference Library > Reference > Mac OS X > Mac OS X Man Pages

 

This document is a Mac OS X manual page. Manual pages are a command-line technology for providing documentation. You can view these manual pages locally using the man(1) command. These manual pages come from many different sources, and thus, have a variety of writing styles.

For more information about the manual page format, see the manual page for manpages(5).



JSON::Syck(3)                        User Contributed Perl Documentation                       JSON::Syck(3)



NAME
       JSON::Syck - JSON is YAML

SYNOPSIS
         use JSON::Syck;

         my $data = JSON::Syck::Load($json);
         my $json = JSON::Syck::Dump($data);

DESCRIPTION
       JSON::Syck is a syck implementatoin of JSON parsing and generation. Because JSON is YAML
       (<http://redhanded.hobix.com/inspect/yamlIsJson.html), using syck gives you the fastest and most
       memory efficient parser and dumper for JSON data representation.

DIFFERENCE WITH JSON
       You might want to know the difference between JSON and JSON::Syck.

       Since JSON is a pure-perl module and JSON::Syck is based on libsyck, JSON::Syck is supposed to be
       very fast and memory efficient. See chansen's benchmark table at
       <http://idisk.mac.com/christian.hansen/Public/perl/serialize.pl

       JSON.pm comes with dozens of ways to do the same thing and lots of options, while JSON::Syck doesn't.
       There's only "Load" and "Dump".

       Oh, and JSON::Syck doesn't use camelCase method names :-)

REFERENCES
       SCALAR REFERNECE

       For now, when you pass a scalar reference to JSON::Syck, it dereferences to get the actual scalar
       value.

       JSON::Syck raises an exception when you pass in circular references.

       If you want to serialize self refernecing stuff, you should use YAML which supports it.

       SUBROUTINE REFERENCE

       When you pass subroutine reference, JSON::Syck dumps it as null.

UTF-8 FLAGS
       By default this module doesn't touch any of utf-8 flags set in strings, and assumes UTF-8 bytes to be
       passed and emit.

       However, when you set $JSON::Syck::ImplicitUnicode to 1, this module properly decodes UTF-8 binaries
       and sets UTF-8 flag everywhere, as in:

         JSON (UTF-8 bytes)   => Perl (UTF-8 flagged)
         JSON (UTF-8 flagged) => Perl (UTF-8 flagged)
         Perl (UTF-8 bytes)   => JSON (UTF-8 flagged)
         Perl (UTF-8 flagged) => JSON (UTF-8 flagged)

       Unfortunately, there's no implicit way to dump Perl UTF-8 flagged data structure to utf-8 encoded
       JSON. To do this, simply use Encode module, e.g.:

         use Encode;
         use JSON::Syck qw(Dump);

         my $json = encode_utf8( Dump($data) );

       Alternatively you can use Encode::JavaScript::UCS to encode Unicode strings as in %uXXXX form.

         use Encode;
         use Encode::JavaScript::UCS;
         use JSON::Syck qw(Dump);

         my $json_unicode_escaped = encode( 'JavaScript-UCS', Dump($data) );

QUOTING
       According to the JSON specification, all JSON strings are to be double-quoted.  However, when
       embedding JavaScript in HTML attributes, it may be more convenient to use single quotes.

       Set $JSON::Syck::SingleQuote to 1 will make both "Dump" and "Load" expect single-quoted string
       literals.

AUTHORS
       Audrey Tang <cpan@audreyt.org>

       Tatsuhiko Miyagawa <miyagawa@gmail.com>

COPYRIGHT
       Copyright 2005, 2006, 2007 by Audrey Tang <cpan@audreyt.org>.

       This software is released under the MIT license cited below.

       The libsyck code bundled with this library is released by "why the lucky stiff", under a BSD-style
       license.  See the COPYING file for details.

       The "MIT" License

       Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
       associated documentation files (the "Software"), to deal in the Software without restriction,
       including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
       and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
       subject to the following conditions:

       The above copyright notice and this permission notice shall be included in all copies or substantial
       portions of the Software.

       THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
       LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
       IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
       LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
       WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.



perl v5.8.8                                      2007-04-20                                    JSON::Syck(3)

Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.