ÿØÿà JFIF    ÿÛ „ ( %!1!%*+...983,7(-.- XS.pm000044400000266002152344454660005455 0ustar00package Cpanel::JSON::XS; our $VERSION = '4.39'; our $XS_VERSION = $VERSION; # $VERSION = eval $VERSION; =pod =head1 NAME Cpanel::JSON::XS - cPanel fork of JSON::XS, fast and correct serializing =head1 SYNOPSIS use Cpanel::JSON::XS; # exported functions, they croak on error # and expect/generate UTF-8 $utf8_encoded_json_text = encode_json $perl_hash_or_arrayref; $perl_hash_or_arrayref = decode_json $utf8_encoded_json_text; # OO-interface $coder = Cpanel::JSON::XS->new->ascii->pretty->allow_nonref; $pretty_printed_unencoded = $coder->encode ($perl_scalar); $perl_scalar = $coder->decode ($unicode_json_text); # Note that 5.6 misses most smart utf8 and encoding functionalities # of newer releases. # Note that L will automatically use Cpanel::JSON::XS # if available, at virtually no speed overhead either, so you should # be able to just: use JSON::MaybeXS; # and do the same things, except that you have a pure-perl fallback now. Note that this module will be replaced by a new JSON::Safe module soon, with the same API just guaranteed safe defaults. =head1 DESCRIPTION This module converts Perl data structures to JSON and vice versa. Its primary goal is to be I and its secondary goal is to be I. To reach the latter goal it was written in C. As this is the n-th-something JSON module on CPAN, what was the reason to write yet another JSON module? While it seems there are many JSON modules, none of them correctly handle all corner cases, and in most cases their maintainers are unresponsive, gone missing, or not listening to bug reports for other reasons. See below for the cPanel fork. See MAPPING, below, on how Cpanel::JSON::XS maps perl values to JSON values and vice versa. =head2 FEATURES =over 4 =item * correct Unicode handling This module knows how to handle Unicode with Perl version higher than 5.8.5, documents how and when it does so, and even documents what "correct" means. =item * round-trip integrity When you serialize a perl data structure using only data types supported by JSON and Perl, the deserialized data structure is identical on the Perl level. (e.g. the string "2.0" doesn't suddenly become "2" just because it looks like a number). There I minor exceptions to this, read the MAPPING section below to learn about those. =item * strict checking of JSON correctness There is no guessing, no generating of illegal JSON texts by default, and only JSON is accepted as input by default. the latter is a security feature. =item * fast Compared to other JSON modules and other serializers such as Storable, this module usually compares favourably in terms of speed, too. =item * simple to use This module has both a simple functional interface as well as an object oriented interface. =item * reasonably versatile output formats You can choose between the most compact guaranteed-single-line format possible (nice for simple line-based protocols), a pure-ASCII format (for when your transport is not 8-bit clean, still supports the whole Unicode range), or a pretty-printed format (for when you want to read that stuff). Or you can combine those features in whatever way you like. =back =head2 cPanel fork Since the original author MLEHMANN has no public bugtracker, this cPanel fork sits now on github. src repo: L original: L RT: L or L B - bare hashkeys are now checked for utf8. (GH #209) - stricter decode_json() as documented. non-refs are disallowed. safe by default. added a 2nd optional argument. decode() honors now allow_nonref. - fixed encode of numbers for dual-vars. Different string representations are preserved, but numbers with temporary strings which represent the same number are here treated as numbers, not strings. Cpanel::JSON::XS is a bit slower, but preserves numeric types better. - numbers ending with .0 stray numbers, are not converted to integers. [#63] dual-vars which are represented as number not integer (42+"bar" != 5.8.9) are now encoded as number (=> 42.0) because internally it's now a NOK type. However !!1 which is wrongly encoded in 5.8 as "1"/1.0 is still represented as integer. - different handling of inf/nan. Default now to null, optionally with stringify_infnan() to "inf"/"nan". [#28, #32] - added C extension, non-JSON and non JSON parsable, allows C<\xNN> and C<\NNN> sequences. - 5.6.2 support; sacrificing some utf8 features (assuming bytes all-over), no multi-byte unicode characters with 5.6. - interop for true/false overloading. JSON::XS, JSON::PP and Mojo::JSON representations for booleans are accepted and JSON::XS accepts Cpanel::JSON::XS booleans [#13, #37] Fixed overloading of booleans. Cpanel::JSON::XS::true stringifies again to "1", not "true", analog to all other JSON modules. - native boolean mapping of yes and no to true and false, as in YAML::XS. In perl C is yes, C is no. The JSON value true maps to 1, false maps to 0. [#39] - support arbitrary stringification with encode, with convert_blessed and allow_blessed. - ithread support. Cpanel::JSON::XS is thread-safe, JSON::XS not - is_bool can be called as method, JSON::XS::is_bool not. - performance optimizations for threaded Perls - relaxed mode, allowing many popular extensions - protect our magic object from corruption by wrong or missing external methods, like FREEZE/THAW or serialization with other methods. - additional fixes for: - #208 - no security-relevant out-of-bounds reading of module memory when decoding hash keys without ending ':' - [cpan #88061] AIX atof without USE_LONG_DOUBLE - #10 unshare_hek crash - #7, #29 avoid re-blessing where possible. It fails in JSON::XS for READONLY values, i.e. restricted hashes. - #41 overloading of booleans, use the object not the reference. - #62 -Dusequadmath conversion and no SEGV. - #72 parsing of values followed \0, like 1\0 does fail. - #72 parsing of illegal unicode or non-unicode characters. - #96 locale-insensitive numeric conversion. - #154 numeric conversion fixed since 5.22, using the same strtold as perl5. - #167 sort tied hashes with canonical. - #212 fix utf8 object stringification - public maintenance and bugtracker - use ppport.h, sanify XS.xs comment styles, harness C coding style - common::sense is optional. When available it is not used in the published production module, just during development and testing. - extended testsuite, passes all http://seriot.ch/projects/parsing_json.html tests. In fact it is the only know JSON decoder which does so, while also being the fastest. - support many more options and methods from JSON::PP: stringify_infnan, allow_unknown, allow_stringify, allow_barekey, encode_stringify, allow_bignum, allow_singlequote, dupkeys_as_arrayref, sort_by (partially), escape_slash, convert_blessed, ... optional decode_json(, allow_nonref) arg. relaxed implements allow_dupkeys. - support all 5 unicode L's: UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, UTF-32BE, encoding internally to UTF-8. =cut our @ISA = qw(Exporter); our @EXPORT = qw(encode_json decode_json to_json from_json); sub to_json($@) { if ($] >= 5.008) { require Carp; Carp::croak ("Cpanel::JSON::XS::to_json has been renamed to encode_json,". " either downgrade to pre-2.0 versions of Cpanel::JSON::XS or". " rename the call"); } else { _to_json(@_); } } sub from_json($@) { if ($] >= 5.008) { require Carp; Carp::croak ("Cpanel::JSON::XS::from_json has been renamed to decode_json,". " either downgrade to pre-2.0 versions of Cpanel::JSON::XS or". " rename the call"); } else { _from_json(@_); } } use Exporter; use XSLoader; =head1 FUNCTIONAL INTERFACE The following convenience methods are provided by this module. They are exported by default: =over 4 =item $json_text = encode_json $perl_scalar, [json_type] Converts the given Perl data structure to a UTF-8 encoded, binary string (that is, the string contains octets only). Croaks on error. This function call is functionally identical to: $json_text = Cpanel::JSON::XS->new->utf8->encode ($perl_scalar, $json_type) Except being faster. For the type argument see L. =item $perl_scalar = decode_json $json_text [, $allow_nonref [, my $json_type ] ] The opposite of C: expects an UTF-8 (binary) string of an json reference and tries to parse that as an UTF-8 encoded JSON text, returning the resulting reference. Croaks on error. This function call is functionally identical to: $perl_scalar = Cpanel::JSON::XS->new->utf8->decode ($json_text, $json_type) except being faster. Note that older decode_json versions in Cpanel::JSON::XS older than 3.0116 and JSON::XS did not set allow_nonref but allowed them due to a bug in the decoder. If the new 2nd optional $allow_nonref argument is set and not false, the C option will be set and the function will act is described as in the relaxed RFC 7159 allowing all values such as objects, arrays, strings, numbers, "null", "true", and "false". See L below, why you don't want to do that. For the 3rd optional type argument see L. =item $is_boolean = Cpanel::JSON::XS::is_bool $scalar Returns true if the passed scalar represents either C or C, two constants that act like C<1> and C<0>, respectively and are used to represent JSON C and C values in Perl. (Also recognizes the booleans produced by L.) See MAPPING, below, for more information on how JSON values are mapped to Perl. =back =head1 DEPRECATED FUNCTIONS =over =item from_json from_json has been renamed to decode_json =item to_json to_json has been renamed to encode_json =back =head1 A FEW NOTES ON UNICODE AND PERL Since this often leads to confusion, here are a few very clear words on how Unicode works in Perl, modulo bugs. =over 4 =item 1. Perl strings can store characters with ordinal values > 255. This enables you to store Unicode characters as single characters in a Perl string - very natural. =item 2. Perl does I associate an encoding with your strings. ... until you force it to, e.g. when matching it against a regex, or printing the scalar to a file, in which case Perl either interprets your string as locale-encoded text, octets/binary, or as Unicode, depending on various settings. In no case is an encoding stored together with your data, it is I that decides encoding, not any magical meta data. =item 3. The internal utf-8 flag has no meaning with regards to the encoding of your string. =item 4. A "Unicode String" is simply a string where each character can be validly interpreted as a Unicode code point. If you have UTF-8 encoded data, it is no longer a Unicode string, but a Unicode string encoded in UTF-8, giving you a binary string. =item 5. A string containing "high" (> 255) character values is I a UTF-8 string. =item 6. Raw non-Unicode characters below U+10FFFF are allowed. The 66 Unicode noncharacters U+FDD0..U+FDEF, and U+*FFFE, U+*FFFF are allowed without warning, as JSON::PP does, see L. But illegal surrogate pairs fail to parse. =item 7. Raw non-Unicode characters above U+10FFFF are disallowed. Raw non-Unicode characters outside the valid unicode range fail to parse, because "A string is a sequence of zero or more Unicode characters" RFC 7159 section 1 and "JSON text SHALL be encoded in Unicode RFC 7159 section 8.1. We use now the UTF8_DISALLOW_SUPER flag when parsing unicode. =item 8. Lone surrogates or illegal surrogate pairs are disallowed. Since RFC 3629, U+D800 through U+DFFF are not legal Unicode values and their UTF-8 encodings must be treated as an invalid byte sequence. RFC 8259 section 8.2 admits the spec allows string values that contain bit sequences that cannot encode Unicode characters and that the behavior of software that receives such values is unpredictable. To avoid introducing non-Unicode strings into Perl we use the UTF8_DISALLOW_SURROGATE flag when parsing Unicode and verify escaped surrogates form valid pairs. =back I hope this helps :) =head1 OBJECT-ORIENTED INTERFACE The object oriented interface lets you configure your own encoding or decoding style, within the limits of supported formats. =over 4 =item $json = new Cpanel::JSON::XS Creates a new JSON object that can be used to de/encode JSON strings. All boolean flags described below are by default I. The mutators for flags all return the JSON object again and thus calls can be chained: my $json = Cpanel::JSON::XS->new->utf8->space_after->encode ({a => [1,2]}) => {"a": [1, 2]} =item $json = $json->ascii ([$enable]) =item $enabled = $json->get_ascii If C<$enable> is true (or missing), then the C method will not generate characters outside the code range C<0..127> (which is ASCII). Any Unicode characters outside that range will be escaped using either a single C<\uXXXX> (BMP characters) or a double C<\uHHHH\uLLLLL> escape sequence, as per RFC4627. The resulting encoded JSON text can be treated as a native Unicode string, an ascii-encoded, latin1-encoded or UTF-8 encoded string, or any other superset of ASCII. If C<$enable> is false, then the C method will not escape Unicode characters unless required by the JSON syntax or other flags. This results in a faster and more compact format. See also the section I later in this document. The main use for this flag is to produce JSON texts that can be transmitted over a 7-bit channel, as the encoded JSON texts will not contain any 8 bit characters. Cpanel::JSON::XS->new->ascii (1)->encode ([chr 0x10401]) => ["\ud801\udc01"] =item $json = $json->latin1 ([$enable]) =item $enabled = $json->get_latin1 If C<$enable> is true (or missing), then the C method will encode the resulting JSON text as latin1 (or ISO-8859-1), escaping any characters outside the code range C<0..255>. The resulting string can be treated as a latin1-encoded JSON text or a native Unicode string. The C method will not be affected in any way by this flag, as C by default expects Unicode, which is a strict superset of latin1. If C<$enable> is false, then the C method will not escape Unicode characters unless required by the JSON syntax or other flags. See also the section I later in this document. The main use for this flag is efficiently encoding binary data as JSON text, as most octets will not be escaped, resulting in a smaller encoded size. The disadvantage is that the resulting JSON text is encoded in latin1 (and must correctly be treated as such when storing and transferring), a rare encoding for JSON. It is therefore most useful when you want to store data structures known to contain binary data efficiently in files or databases, not when talking to other JSON encoders/decoders. Cpanel::JSON::XS->new->latin1->encode (["\x{89}\x{abc}"] => ["\x{89}\\u0abc"] # (perl syntax, U+abc escaped, U+89 not) =item $json = $json->binary ([$enable]) =item $enabled = $json = $json->get_binary If the C<$enable> argument is true (or missing), then the C method will not try to detect an UTF-8 encoding in any JSON string, it will strictly interpret it as byte sequence. The result might contain new C<\xNN> sequences, which is B. The C method forbids C<\uNNNN> sequences and accepts C<\xNN> and octal C<\NNN> sequences. There is also a special logic for perl 5.6 and utf8. 5.6 encodes any string to utf-8 automatically when seeing a codepoint >= C<0x80> and < C<0x100>. With the binary flag enabled decode the perl utf8 encoded string to the original byte encoding and encode this with C<\xNN> escapes. This will result to the same encodings as with newer perls. But note that binary multi-byte codepoints with 5.6 will result in C errors, unlike with newer perls. If C<$enable> is false, then the C method will smartly try to detect Unicode characters unless required by the JSON syntax or other flags and hex and octal sequences are forbidden. See also the section I later in this document. The main use for this flag is to avoid the smart unicode detection and possible double encoding. The disadvantage is that the resulting JSON text is encoded in new C<\xNN> and in latin1 characters and must correctly be treated as such when storing and transferring, a rare encoding for JSON. It will produce non-readable JSON strings in the browser. It is therefore most useful when you want to store data structures known to contain binary data efficiently in files or databases, not when talking to other JSON encoders/decoders. The binary decoding method can also be used when an encoder produced a non-JSON conformant hex or octal encoding C<\xNN> or C<\NNN>. Cpanel::JSON::XS->new->binary->encode (["\x{89}\x{abc}"]) 5.6: Error: malformed or illegal unicode character in binary string >=5.8: ['\x89\xe0\xaa\xbc'] Cpanel::JSON::XS->new->binary->encode (["\x{89}\x{bc}"]) => ["\x89\xbc"] Cpanel::JSON::XS->new->binary->decode (["\x89\ua001"]) Error: malformed or illegal unicode character in binary string Cpanel::JSON::XS->new->decode (["\x89"]) Error: illegal hex character in non-binary string =item $json = $json->utf8 ([$enable]) =item $enabled = $json->get_utf8 If C<$enable> is true (or missing), then the C method will encode the JSON result into UTF-8, as required by many protocols, while the C method expects to be handled an UTF-8-encoded string. Please note that UTF-8-encoded strings do not contain any characters outside the range C<0..255>, they are thus useful for bytewise/binary I/O. In future versions, enabling this option might enable autodetection of the UTF-16 and UTF-32 encoding families, as described in RFC4627. If C<$enable> is false, then the C method will return the JSON string as a (non-encoded) Unicode string, while C expects thus a Unicode string. Any decoding or encoding (e.g. to UTF-8 or UTF-16) needs to be done yourself, e.g. using the Encode module. See also the section I later in this document. Example, output UTF-16BE-encoded JSON: use Encode; $jsontext = encode "UTF-16BE", Cpanel::JSON::XS->new->encode ($object); Example, decode UTF-32LE-encoded JSON: use Encode; $object = Cpanel::JSON::XS->new->decode (decode "UTF-32LE", $jsontext); =item $json = $json->pretty ([$enable]) This enables (or disables) all of the C, C and C (and in the future possibly more) flags in one call to generate the most readable (or most compact) form possible. Example, pretty-print some simple structure: my $json = Cpanel::JSON::XS->new->pretty(1)->encode ({a => [1,2]}) => { "a" : [ 1, 2 ] } =item $json = $json->indent ([$enable]) =item $enabled = $json->get_indent If C<$enable> is true (or missing), then the C method will use a multiline format as output, putting every array member or object/hash key-value pair into its own line, indenting them properly. If C<$enable> is false, no newlines or indenting will be produced, and the resulting JSON text is guaranteed not to contain any C. This setting has no effect when decoding JSON texts. =item $json = $json->indent_length([$number_of_spaces]) =item $length = $json->get_indent_length() Set the indent length (default C<3>). This option is only useful when you also enable indent or pretty. The acceptable range is from 0 (no indentation) to 15 =item $json = $json->space_before ([$enable]) =item $enabled = $json->get_space_before If C<$enable> is true (or missing), then the C method will add an extra optional space before the C<:> separating keys from values in JSON objects. If C<$enable> is false, then the C method will not add any extra space at those places. This setting has no effect when decoding JSON texts. You will also most likely combine this setting with C. Example, space_before enabled, space_after and indent disabled: {"key" :"value"} =item $json = $json->space_after ([$enable]) =item $enabled = $json->get_space_after If C<$enable> is true (or missing), then the C method will add an extra optional space after the C<:> separating keys from values in JSON objects and extra whitespace after the C<,> separating key-value pairs and array members. If C<$enable> is false, then the C method will not add any extra space at those places. This setting has no effect when decoding JSON texts. Example, space_before and indent disabled, space_after enabled: {"key": "value"} =item $json = $json->relaxed ([$enable]) =item $enabled = $json->get_relaxed If C<$enable> is true (or missing), then C will accept some extensions to normal JSON syntax (see below). C will not be affected in anyway. I. I suggest only to use this option to parse application-specific files written by humans (configuration files, resource files etc.) If C<$enable> is false (the default), then C will only accept valid JSON texts. Currently accepted extensions are: =over 4 =item * list items can have an end-comma JSON I array elements and key-value pairs with commas. This can be annoying if you write JSON texts manually and want to be able to quickly append elements, so this extension accepts comma at the end of such items not just between them: [ 1, 2, <- this comma not normally allowed ] { "k1": "v1", "k2": "v2", <- this comma not normally allowed } =item * shell-style '#'-comments Whenever JSON allows whitespace, shell-style comments are additionally allowed. They are terminated by the first carriage-return or line-feed character, after which more white-space and comments are allowed. [ 1, # this comment not allowed in JSON # neither this one... ] =item * literal ASCII TAB characters in strings Literal ASCII TAB characters are now allowed in strings (and treated as C<\t>) in relaxed mode. Despite JSON mandates, that TAB character is substituted for "\t" sequence. [ "Hello\tWorld", "HelloWorld", # literal would not normally be allowed ] =item * allow_singlequote Single quotes are accepted instead of double quotes. See the L option. { "foo":'bar' } { 'foo':"bar" } { 'foo':'bar' } =item * allow_barekey Accept unquoted object keys instead of with mandatory double quotes. See the L option. { foo:"bar" } =item * allow_dupkeys Allow decoding of duplicate keys in hashes. By default duplicate keys are forbidden. See L: RFC 7159 section 4: "The names within an object should be unique." See the C option. =back =item $json = $json->canonical ([$enable]) =item $enabled = $json->get_canonical If C<$enable> is true (or missing), then the C method will output JSON objects by sorting their keys. This is adding a comparatively high overhead. If C<$enable> is false, then the C method will output key-value pairs in the order Perl stores them (which will likely change between runs of the same script, and can change even within the same run from 5.18 onwards). This option is useful if you want the same data structure to be encoded as the same JSON text (given the same overall settings). If it is disabled, the same hash might be encoded differently even if contains the same data, as key-value pairs have no inherent ordering in Perl. This setting has no effect when decoding JSON texts. This is now also done with tied hashes, contrary to L. But note that with most large tied hashes stored as tree it is advised to sort the iterator already and don't sort the hash output here. Most such iterators are already sorted, as such e.g. L with C. =item $json = $json->sort_by (undef, 0, 1 or a block) This currently only (un)sets the C option, and ignores custom sort blocks. This setting has no effect when decoding JSON texts. This setting has currently no effect on tied hashes. =item $json = $json->escape_slash ([$enable]) =item $enabled = $json->get_escape_slash According to the JSON Grammar, the I character (U+002F) C<"/"> need to be escaped. But by default strings are encoded without escaping slashes in all perl JSON encoders. If C<$enable> is true (or missing), then C will escape slashes, C<"\/">. This setting has no effect when decoding JSON texts. =item $json = $json->unblessed_bool ([$enable]) =item $enabled = $json->get_unblessed_bool $json = $json->unblessed_bool([$enable]) If C<$enable> is true (or missing), then C will return Perl non-object boolean variables (1 and 0 as numbers or "1" and "" as strings) for JSON booleans (C and C). If C<$enable> is false, then C will return C objects for JSON booleans. =item $json = $json->allow_singlequote ([$enable]) =item $enabled = $json->get_allow_singlequote $json = $json->allow_singlequote([$enable]) If C<$enable> is true (or missing), then C will accept JSON strings quoted by single quotations that are invalid JSON format. $json->allow_singlequote->decode({"foo":'bar'}); $json->allow_singlequote->decode({'foo':"bar"}); $json->allow_singlequote->decode({'foo':'bar'}); This is also enabled with C. As same as the C option, this option may be used to parse application-specific files written by humans. =item $json = $json->allow_barekey ([$enable]) =item $enabled = $json->get_allow_barekey $json = $json->allow_barekey([$enable]) If C<$enable> is true (or missing), then C will accept bare keys of JSON object that are invalid JSON format. Same as with the C option, this option may be used to parse application-specific files written by humans. $json->allow_barekey->decode('{foo:"bar"}'); =item $json = $json->allow_bignum ([$enable]) =item $enabled = $json->get_allow_bignum $json = $json->allow_bignum([$enable]) If C<$enable> is true (or missing), then C will convert the big integer Perl cannot handle as integer into a L object and convert a floating number (any) into a L. $int = $json->allow_nonref->allow_bignum->decode(1); # => 1 $bigint = $json->allow_bignum->decode('100000000000000000000000000000000000000'); $bigfloat = $json->allow_bignum->decode(1.0); On the contrary, C converts C objects and C objects into JSON numbers with C enable. $json->allow_nonref->allow_blessed->allow_bignum; $bigfloat = $json->decode('2.000000000000000000000000001'); print $json->encode($bigfloat); # => 2.000000000000000000000000001 See L about the normal conversion of JSON number. =item $json = $json->allow_bigint ([$enable]) This option is obsolete and replaced by allow_bignum. =item $json = $json->allow_nonref ([$enable]) =item $enabled = $json->get_allow_nonref If C<$enable> is true (or missing), then the C method can convert a non-reference into its corresponding string, number or null JSON value, which is an extension to RFC4627. Likewise, C will accept those JSON values instead of croaking. If C<$enable> is false, then the C method will croak if it isn't passed an arrayref or hashref, as JSON texts must either be an object or array. Likewise, C will croak if given something that is not a JSON object or array. Example, encode a Perl scalar as JSON value with enabled C, resulting in an invalid JSON text: Cpanel::JSON::XS->new->allow_nonref->encode ("Hello, World!") => "Hello, World!" =item $json = $json->allow_unknown ([$enable]) =item $enabled = $json->get_allow_unknown If C<$enable> is true (or missing), then C will I throw an exception when it encounters values it cannot represent in JSON (for example, filehandles) but instead will encode a JSON C value. Note that blessed objects are not included here and are handled separately by c. If C<$enable> is false (the default), then C will throw an exception when it encounters anything it cannot encode as JSON. This option does not affect C in any way, and it is recommended to leave it off unless you know your communications partner. =item $json = $json->allow_stringify ([$enable]) =item $enabled = $json->get_allow_stringify If C<$enable> is true (or missing), then C will stringify the non-object perl value or reference. Note that blessed objects are not included here and are handled separately by C and C. String references are stringified to the string value, other references as in perl. This option does not affect C in any way. This option is special to this module, it is not supported by other encoders. So it is not recommended to use it. =item $json = $json->require_types ([$enable]) =item $enable = $json->get_require_types $json = $json->require_types([$enable]) If C<$enable> is true (or missing), then C will require either enabled C or second argument with supplied JSON types. See L. When C is not enabled or second argument is not provided (or is undef), then C croaks. It also croaks when the type for provided structure in C is incomplete. =item $json = $json->type_all_string ([$enable]) =item $enable = $json->get_type_all_string $json = $json->type_all_string([$enable]) If C<$enable> is true (or missing), then C will always produce stable deterministic JSON string types in resulted output. When C<$enable> is false, then result of encoded JSON output may be different for different Perl versions and may depends on loaded modules. This is useful it you need deterministic JSON types, independently of used Perl version and other modules, but do not want to write complicated type definitions for L. =item $json = $json->allow_dupkeys ([$enable]) =item $enabled = $json->get_allow_dupkeys If C<$enable> is true (or missing), then the C method will not die when it encounters duplicate keys in a hash. C is also enabled in the C mode. The JSON spec allows duplicate name in objects but recommends to disable it, however with Perl hashes they are impossible, parsing JSON in Perl silently ignores duplicate names, using the last value found. See L: RFC 7159 section 4: "The names within an object should be unique." =item $json = $json->dupkeys_as_arrayref ([$enable]) =item $enabled = $json->get_dupkeys_as_arrayref If enabled, allow decoding of duplicate keys in hashes and store the values as arrayref in the hash instead. By default duplicate keys are forbidden. Enabling this also enables the L option, but disabling this does not disable the L option. Example: $json->dupkeys_as_arrayref; print encode_json ($json->decode ('{"a":"b","a":"c"}')); => {"a":["b","c"]} This changes the result structure, thus cannot be enabled by default. The client must be aware of it. The resulting arrayref is not yet marked somehow (blessed or such). =item $json = $json->allow_blessed ([$enable]) =item $enabled = $json->get_allow_blessed If C<$enable> is true (or missing), then the C method will not barf when it encounters a blessed reference. Instead, the value of the B option will decide whether C (C disabled or no C method found) or a representation of the object (C enabled and C method found) is being encoded. Has no effect on C. If C<$enable> is false (the default), then C will throw an exception when it encounters a blessed object without C and a C method. This setting has no effect on C. =item $json = $json->convert_blessed ([$enable]) =item $enabled = $json->get_convert_blessed If C<$enable> is true (or missing), then C, upon encountering a blessed object, will check for the availability of the C method on the object's class. If found, it will be called in scalar context and the resulting scalar will be encoded instead of the object. If no C method is found, a stringification overload method is tried next. If both are not found, the value of C will decide what to do. The C method may safely call die if it wants. If C returns other blessed objects, those will be handled in the same way. C must take care of not causing an endless recursion cycle (== crash) in this case. The same care must be taken with calling encode in stringify overloads (even if this works by luck in older perls) or other callbacks. The name of C was chosen because other methods called by the Perl core (== not by the user of the object) are usually in upper case letters and to avoid collisions with any C function or method. If C<$enable> is false (the default), then C will not consider this type of conversion. This setting has no effect on C. =item $json = $json->allow_tags ([$enable]) =item $enabled = $json->get_allow_tags See L for details. If C<$enable> is true (or missing), then C, upon encountering a blessed object, will check for the availability of the C method on the object's class. If found, it will be used to serialize the object into a nonstandard tagged JSON value (that JSON decoders cannot decode). It also causes C to parse such tagged JSON values and deserialize them via a call to the C method. If C<$enable> is false (the default), then C will not consider this type of conversion, and tagged JSON values will cause a parse error in C, as if tags were not part of the grammar. =item $json = $json->filter_json_object ([$coderef->($hashref)]) When C<$coderef> is specified, it will be called from C each time it decodes a JSON object. The only argument is a reference to the newly-created hash. If the code references returns a single scalar (which need not be a reference), this value (i.e. a copy of that scalar to avoid aliasing) is inserted into the deserialized data structure. If it returns an empty list (NOTE: I C, which is a valid scalar), the original deserialized hash will be inserted. This setting can slow down decoding considerably. When C<$coderef> is omitted or undefined, any existing callback will be removed and C will not change the deserialized hash in any way. Example, convert all JSON objects into the integer 5: my $js = Cpanel::JSON::XS->new->filter_json_object (sub { 5 }); # returns [5] $js->decode ('[{}]') # throw an exception because allow_nonref is not enabled # so a lone 5 is not allowed. $js->decode ('{"a":1, "b":2}'); =item $json = $json->filter_json_single_key_object ($key [=> $coderef->($value)]) Works remotely similar to C, but is only called for JSON objects having a single key named C<$key>. This C<$coderef> is called before the one specified via C, if any. It gets passed the single value in the JSON object. If it returns a single value, it will be inserted into the data structure. If it returns nothing (not even C but the empty list), the callback from C will be called next, as if no single-key callback were specified. If C<$coderef> is omitted or undefined, the corresponding callback will be disabled. There can only ever be one callback for a given key. As this callback gets called less often then the C one, decoding speed will not usually suffer as much. Therefore, single-key objects make excellent targets to serialize Perl objects into, especially as single-key JSON objects are as close to the type-tagged value concept as JSON gets (it's basically an ID/VALUE tuple). Of course, JSON does not support this in any way, so you need to make sure your data never looks like a serialized Perl hash. Typical names for the single object key are C<__class_whatever__>, or C<$__dollars_are_rarely_used__$> or C<}ugly_brace_placement>, or even things like C<__class_md5sum(classname)__>, to reduce the risk of clashing with real hashes. Example, decode JSON objects of the form C<< { "__widget__" => } >> into the corresponding C<< $WIDGET{} >> object: # return whatever is in $WIDGET{5}: Cpanel::JSON::XS ->new ->filter_json_single_key_object (__widget__ => sub { $WIDGET{ $_[0] } }) ->decode ('{"__widget__": 5') # this can be used with a TO_JSON method in some "widget" class # for serialization to json: sub WidgetBase::TO_JSON { my ($self) = @_; unless ($self->{id}) { $self->{id} = ..get..some..id..; $WIDGET{$self->{id}} = $self; } { __widget__ => $self->{id} } } =item $json = $json->shrink ([$enable]) =item $enabled = $json->get_shrink Perl usually over-allocates memory a bit when allocating space for strings. This flag optionally resizes strings generated by either C or C to their minimum size possible. This can save memory when your JSON texts are either very very long or you have many short strings. It will also try to downgrade any strings to octet-form if possible: perl stores strings internally either in an encoding called UTF-X or in octet-form. The latter cannot store everything but uses less space in general (and some buggy Perl or C code might even rely on that internal representation being used). The actual definition of what shrink does might change in future versions, but it will always try to save space at the expense of time. If C<$enable> is true (or missing), the string returned by C will be shrunk-to-fit, while all strings generated by C will also be shrunk-to-fit. If C<$enable> is false, then the normal perl allocation algorithms are used. If you work with your data, then this is likely to be faster. In the future, this setting might control other things, such as converting strings that look like integers or floats into integers or floats internally (there is no difference on the Perl level), saving space. =item $json = $json->max_depth ([$maximum_nesting_depth]) =item $max_depth = $json->get_max_depth Sets the maximum nesting level (default C<512>) accepted while encoding or decoding. If a higher nesting level is detected in JSON text or a Perl data structure, then the encoder and decoder will stop and croak at that point. Nesting level is defined by number of hash- or arrayrefs that the encoder needs to traverse to reach a given point or the number of C<{> or C<[> characters without their matching closing parenthesis crossed to reach a given character in a string. Setting the maximum depth to one disallows any nesting, so that ensures that the object is only a single hash/object or array. If no argument is given, the highest possible setting will be used, which is rarely useful. Note that nesting is implemented by recursion in C. The default value has been chosen to be as large as typical operating systems allow without crashing. See L, below, for more info on why this is useful. =item $json = $json->max_size ([$maximum_string_size]) =item $max_size = $json->get_max_size Set the maximum length a JSON text may have (in bytes) where decoding is being attempted. The default is C<0>, meaning no limit. When C is called on a string that is longer then this many bytes, it will not attempt to decode the string but throw an exception. This setting has no effect on C (yet). If no argument is given, the limit check will be deactivated (same as when C<0> is specified). See L, below, for more info on why this is useful. =item $json->stringify_infnan ([$infnan_mode = 1]) =item $infnan_mode = $json->get_stringify_infnan Get or set how Cpanel::JSON::XS encodes C, C<-inf> or C for numeric values. Also qnan, snan or negative nan on some platforms. C: infnan_mode = 0. Similar to most JSON modules in other languages. Always null. stringified: infnan_mode = 1. As in Mojo::JSON. Platform specific strings. Stringified via sprintf(%g), with double quotes. inf/nan: infnan_mode = 2. As in JSON::XS, and older releases. Passes through platform dependent values, invalid JSON. Stringified via sprintf(%g), but without double quotes. "inf/-inf/nan": infnan_mode = 3. Platform independent inf/nan/-inf strings. No QNAN/SNAN/negative NAN support, unified to "nan". Much easier to detect, but may conflict with valid strings. =item $json_text = $json->encode ($perl_scalar, $json_type) Converts the given Perl data structure (a simple scalar or a reference to a hash or array) to its JSON representation. Simple scalars will be converted into JSON string or number sequences, while references to arrays become JSON arrays and references to hashes become JSON objects. Undefined Perl values (e.g. C) become JSON C values. Neither C nor C values will be generated. For the type argument see L. =item $perl_scalar = $json->decode ($json_text, my $json_type) The opposite of C: expects a JSON text and tries to parse it, returning the resulting simple scalar or reference. Croaks on error. JSON numbers and strings become simple Perl scalars. JSON arrays become Perl arrayrefs and JSON objects become Perl hashrefs. C becomes C<1>, C becomes C<0> and C becomes C. For the type argument see L. =item ($perl_scalar, $characters) = $json->decode_prefix ($json_text) This works like the C method, but instead of raising an exception when there is trailing garbage after the first JSON object, it will silently stop parsing there and return the number of characters consumed so far. This is useful if your JSON texts are not delimited by an outer protocol and you need to know where the JSON text ends. Cpanel::JSON::XS->new->decode_prefix ("[1] the tail") => ([1], 3) =item $json->to_json ($perl_hash_or_arrayref) Deprecated method for perl 5.8 and newer. Use L instead. =item $json->from_json ($utf8_encoded_json_text) Deprecated method for perl 5.8 and newer. Use L instead. =back =head1 INCREMENTAL PARSING In some cases, there is the need for incremental parsing of JSON texts. While this module always has to keep both JSON text and resulting Perl data structure in memory at one time, it does allow you to parse a JSON stream incrementally. It does so by accumulating text until it has a full JSON object, which it then can decode. This process is similar to using C to see if a full JSON object is available, but is much more efficient (and can be implemented with a minimum of method calls). Cpanel::JSON::XS will only attempt to parse the JSON text once it is sure it has enough text to get a decisive result, using a very simple but truly incremental parser. This means that it sometimes won't stop as early as the full parser, for example, it doesn't detect mismatched parentheses. The only thing it guarantees is that it starts decoding as soon as a syntactically valid JSON text has been seen. This means you need to set resource limits (e.g. C) to ensure the parser will stop parsing in the presence of syntax errors. The following methods implement this incremental parser. =over 4 =item [void, scalar or list context] = $json->incr_parse ([$string]) This is the central parsing function. It can both append new text and extract objects from the stream accumulated so far (both of these functions are optional). If C<$string> is given, then this string is appended to the already existing JSON fragment stored in the C<$json> object. After that, if the function is called in void context, it will simply return without doing anything further. This can be used to add more text in as many chunks as you want. If the method is called in scalar context, then it will try to extract exactly I JSON object. If that is successful, it will return this object, otherwise it will return C. If there is a parse error, this method will croak just as C would do (one can then use C to skip the erroneous part). This is the most common way of using the method. And finally, in list context, it will try to extract as many objects from the stream as it can find and return them, or the empty list otherwise. For this to work, there must be no separators between the JSON objects or arrays, instead they must be concatenated back-to-back. If an error occurs, an exception will be raised as in the scalar context case. Note that in this case, any previously-parsed JSON texts will be lost. Example: Parse some JSON arrays/objects in a given string and return them. my @objs = Cpanel::JSON::XS->new->incr_parse ("[5][7][1,2]"); =item $lvalue_string = $json->incr_text (>5.8 only) This method returns the currently stored JSON fragment as an lvalue, that is, you can manipulate it. This I works when a preceding call to C in I successfully returned an object, and 2. only with Perl >= 5.8 Under all other circumstances you must not call this function (I mean it. although in simple tests it might actually work, it I fail under real world conditions). As a special exception, you can also call this method before having parsed anything. This function is useful in two cases: a) finding the trailing text after a JSON object or b) parsing multiple JSON objects separated by non-JSON text (such as commas). =item $json->incr_skip This will reset the state of the incremental parser and will remove the parsed text from the input buffer so far. This is useful after C died, in which case the input buffer and incremental parser state is left unchanged, to skip the text parsed so far and to reset the parse state. The difference to C is that only text until the parse error occurred is removed. =item $json->incr_reset This completely resets the incremental parser, that is, after this call, it will be as if the parser had never parsed anything. This is useful if you want to repeatedly parse JSON objects and want to ignore any trailing data, which means you have to reset the parser after each successful decode. =back =head2 LIMITATIONS All options that affect decoding are supported, except C. The reason for this is that it cannot be made to work sensibly: JSON objects and arrays are self-delimited, i.e. you can concatenate them back to back and still decode them perfectly. This does not hold true for JSON numbers, however. For example, is the string C<1> a single JSON number, or is it simply the start of C<12>? Or is C<12> a single JSON number, or the concatenation of C<1> and C<2>? In neither case you can tell, and this is why Cpanel::JSON::XS takes the conservative route and disallows this case. =head2 EXAMPLES Some examples will make all this clearer. First, a simple example that works similarly to C: We want to decode the JSON object at the start of a string and identify the portion after the JSON object: my $text = "[1,2,3] hello"; my $json = new Cpanel::JSON::XS; my $obj = $json->incr_parse ($text) or die "expected JSON object or array at beginning of string"; my $tail = $json->incr_text; # $tail now contains " hello" Easy, isn't it? Now for a more complicated example: Imagine a hypothetical protocol where you read some requests from a TCP stream, and each request is a JSON array, without any separation between them (in fact, it is often useful to use newlines as "separators", as these get interpreted as whitespace at the start of the JSON text, which makes it possible to test said protocol with C...). Here is how you'd do it (it is trivial to write this in an event-based manner): my $json = new Cpanel::JSON::XS; # read some data from the socket while (sysread $socket, my $buf, 4096) { # split and decode as many requests as possible for my $request ($json->incr_parse ($buf)) { # act on the $request } } Another complicated example: Assume you have a string with JSON objects or arrays, all separated by (optional) comma characters (e.g. C<[1],[2], [3]>). To parse them, we have to skip the commas between the JSON texts, and here is where the lvalue-ness of C comes in useful: my $text = "[1],[2], [3]"; my $json = new Cpanel::JSON::XS; # void context, so no parsing done $json->incr_parse ($text); # now extract as many objects as possible. note the # use of scalar context so incr_text can be called. while (my $obj = $json->incr_parse) { # do something with $obj # now skip the optional comma $json->incr_text =~ s/^ \s* , //x; } Now lets go for a very complex example: Assume that you have a gigantic JSON array-of-objects, many gigabytes in size, and you want to parse it, but you cannot load it into memory fully (this has actually happened in the real world :). Well, you lost, you have to implement your own JSON parser. But Cpanel::JSON::XS can still help you: You implement a (very simple) array parser and let JSON decode the array elements, which are all full JSON objects on their own (this wouldn't work if the array elements could be JSON numbers, for example): my $json = new Cpanel::JSON::XS; # open the monster open my $fh, "incr_parse ($buf); # void context, so no parsing # Exit the loop once we found and removed(!) the initial "[". # In essence, we are (ab-)using the $json object as a simple scalar # we append data to. last if $json->incr_text =~ s/^ \s* \[ //x; } # now we have the skipped the initial "[", so continue # parsing all the elements. for (;;) { # in this loop we read data until we got a single JSON object for (;;) { if (my $obj = $json->incr_parse) { # do something with $obj last; } # add more data sysread $fh, my $buf, 65536 or die "read error: $!"; $json->incr_parse ($buf); # void context, so no parsing } # in this loop we read data until we either found and parsed the # separating "," between elements, or the final "]" for (;;) { # first skip whitespace $json->incr_text =~ s/^\s*//; # if we find "]", we are done if ($json->incr_text =~ s/^\]//) { print "finished.\n"; exit; } # if we find ",", we can continue with the next element if ($json->incr_text =~ s/^,//) { last; } # if we find anything else, we have a parse error! if (length $json->incr_text) { die "parse error near ", $json->incr_text; } # else add more data sysread $fh, my $buf, 65536 or die "read error: $!"; $json->incr_parse ($buf); # void context, so no parsing } This is a complex example, but most of the complexity comes from the fact that we are trying to be correct (bear with me if I am wrong, I never ran the above example :). =head1 BOM Detect all unicode B on decode. Which are UTF-8, UTF-16LE, UTF-16BE, UTF-32LE and UTF-32BE. The BOM encoding is set only for one specific decode call, it does not change the state of the JSON object. B: With perls older than 5.20 you need load the Encode module before loading a multibyte BOM, i.e. >= UTF-16. Otherwise an error is thrown. This is an implementation limitation and might get fixed later. See L I<"JSON text SHALL be encoded in UTF-8, UTF-16, or UTF-32."> I<"Implementations MUST NOT add a byte order mark to the beginning of a JSON text", "implementations (...) MAY ignore the presence of a byte order mark rather than treating it as an error".> See also L. Beware that Cpanel::JSON::XS is currently the only JSON module which does accept and decode a BOM. The latest JSON spec L forbid the usage of UTF-16 or UTF-32, the character encoding is UTF-8. Thus in subsequent updates BOM's of UTF-16 or UTF-32 will throw an error. =head1 MAPPING This section describes how Cpanel::JSON::XS maps Perl values to JSON values and vice versa. These mappings are designed to "do the right thing" in most circumstances automatically, preserving round-tripping characteristics (what you put in comes out as something equivalent). For the more enlightened: note that in the following descriptions, lowercase I refers to the Perl interpreter, while uppercase I refers to the abstract Perl language itself. =head2 JSON -> PERL =over 4 =item object A JSON object becomes a reference to a hash in Perl. No ordering of object keys is preserved (JSON does not preserve object key ordering itself). =item array A JSON array becomes a reference to an array in Perl. =item string A JSON string becomes a string scalar in Perl - Unicode codepoints in JSON are represented by the same codepoints in the Perl string, so no manual decoding is necessary. =item number A JSON number becomes either an integer, numeric (floating point) or string scalar in perl, depending on its range and any fractional parts. On the Perl level, there is no difference between those as Perl handles all the conversion details, but an integer may take slightly less memory and might represent more values exactly than floating point numbers. If the number consists of digits only, Cpanel::JSON::XS will try to represent it as an integer value. If that fails, it will try to represent it as a numeric (floating point) value if that is possible without loss of precision. Otherwise it will preserve the number as a string value (in which case you lose roundtripping ability, as the JSON number will be re-encoded to a JSON string). Numbers containing a fractional or exponential part will always be represented as numeric (floating point) values, possibly at a loss of precision (in which case you might lose perfect roundtripping ability, but the JSON number will still be re-encoded as a JSON number). Note that precision is not accuracy - binary floating point values cannot represent most decimal fractions exactly, and when converting from and to floating point, C only guarantees precision up to but not including the least significant bit. =item true, false When C is set to true, then JSON C becomes C<1> and JSON C becomes C<0>. Otherwise these JSON atoms become C and C, respectively. They are C objects and are overloaded to act almost exactly like the numbers C<1> and C<0>. You can check whether a scalar is a JSON boolean by using the C function. The other round, from perl to JSON, C which is represented as C becomes C, and C which is represented as C becomes C. Via L you can now even force negation in C, without overloading of C: my $false = Cpanel::JSON::XS::false; print($json->encode([!$false], [JSON_TYPE_BOOL])); => [true] =item null A JSON null atom becomes C in Perl. =item shell-style comments (C<< # I >>) As a nonstandard extension to the JSON syntax that is enabled by the C setting, shell-style comments are allowed. They can start anywhere outside strings and go till the end of the line. =item tagged values (C<< (I)I >>). Another nonstandard extension to the JSON syntax, enabled with the C setting, are tagged values. In this implementation, the I must be a perl package/class name encoded as a JSON string, and the I must be a JSON array encoding optional constructor arguments. See L, below, for details. =back =head2 PERL -> JSON The mapping from Perl to JSON is slightly more difficult, as Perl is a truly typeless language, so we can only guess which JSON type is meant by a Perl value. =over 4 =item hash references Perl hash references become JSON objects. As there is no inherent ordering in hash keys (or JSON objects), they will usually be encoded in a pseudo-random order that can change between runs of the same program but stays generally the same within a single run of a program. Cpanel::JSON::XS can optionally sort the hash keys (determined by the I flag), so the same datastructure will serialize to the same JSON text (given same settings and version of Cpanel::JSON::XS), but this incurs a runtime overhead and is only rarely useful, e.g. when you want to compare some JSON text against another for equality. =item array references Perl array references become JSON arrays. =item other references Other unblessed references are generally not allowed and will cause an exception to be thrown, except for references to the integers C<0> and C<1>, which get turned into C and C atoms in JSON. With the option C, you can ignore the exception and return the stringification of the perl value. With the option C, you can ignore the exception and return C instead. encode_json [\"x"] # => cannot encode reference to scalar 'SCALAR(0x..)' # unless the scalar is 0 or 1 encode_json [\0, \1] # yields [false,true] allow_stringify->encode_json [\"x"] # yields "x" unlike JSON::PP allow_unknown->encode_json [\"x"] # yields null as in JSON::PP =item Cpanel::JSON::XS::true, Cpanel::JSON::XS::false These special values become JSON true and JSON false values, respectively. You can also use C<\1> and C<\0> or C and C directly if you want. encode_json [Cpanel::JSON::XS::false, Cpanel::JSON::XS::true] # yields [false,true] encode_json [!1, !0], [JSON_TYPE_BOOL, JSON_TYPE_BOOL] # yields [false,true] eq/ne comparisons with true, false: false is eq to the empty string or the string 'false' or the special empty string C or C, i.e. C, or the numbers 0 or 0.0. true is eq to the string 'true' or to the special string C (i.e. C) or to the numbers 1 or 1.0. =item blessed objects Blessed objects are not directly representable in JSON, but C allows various optional ways of handling objects. See L, below, for details. See the C and C methods on various options on how to deal with this: basically, you can choose between throwing an exception, encoding the reference as if it weren't blessed, use the objects overloaded stringification method or provide your own serializer method. =item simple scalars Simple Perl scalars (any scalar that is not a reference) are the most difficult objects to encode: Cpanel::JSON::XS will encode undefined scalars or inf/nan as JSON C values and other scalars to either number or string in non-deterministic way which may be affected or changed by Perl version or any other loaded Perl module. If you want to have stable and deterministic types in JSON encoder then use L. Alternative way for deterministic types is to use C method when all perl scalars are encoded to JSON strings. Non-deterministic behavior is following: scalars that have last been used in a string context before encoding as JSON strings, and anything else as number value: # dump as number encode_json [2] # yields [2] encode_json [-3.0e17] # yields [-3e+17] my $value = 5; encode_json [$value] # yields [5] # used as string, but the two representations are for the same number print $value; encode_json [$value] # yields [5] # used as different string (non-matching dual-var) my $str = '0 but true'; my $num = 1 + $str; encode_json [$num, $str] # yields [1,"0 but true"] # undef becomes null encode_json [undef] # yields [null] # inf or nan becomes null, unless you answered # "Do you want to handle inf/nan as strings" with yes encode_json [9**9**9] # yields [null] You can force the type to be a JSON string by stringifying it: my $x = 3.1; # some variable containing a number "$x"; # stringified $x .= ""; # another, more awkward way to stringify print $x; # perl does it for you, too, quite often You can force the type to be a JSON number by numifying it: my $x = "3"; # some variable containing a string $x += 0; # numify it, ensuring it will be dumped as a number $x *= 1; # same thing, the choice is yours. Note that numerical precision has the same meaning as under Perl (so binary to decimal conversion follows the same rules as in Perl, which can differ to other languages). Also, your perl interpreter might expose extensions to the floating point numbers of your platform, such as infinities or NaN's - these cannot be represented in JSON, and thus null is returned instead. Optionally you can configure it to stringify inf and nan values. =back =head2 OBJECT SERIALIZATION As JSON cannot directly represent Perl objects, you have to choose between a pure JSON representation (without the ability to deserialize the object automatically again), and a nonstandard extension to the JSON syntax, tagged values. =head3 SERIALIZATION What happens when C encounters a Perl object depends on the C, C and C settings, which are used in this order: =over 4 =item 1. C is enabled and the object has a C method. In this case, C uses the L object serialization protocol to create a tagged JSON value, using a nonstandard extension to the JSON syntax. This works by invoking the C method on the object, with the first argument being the object to serialize, and the second argument being the constant string C to distinguish it from other serializers. The C method can return any number of values (i.e. zero or more). These values and the paclkage/classname of the object will then be encoded as a tagged JSON value in the following format: ("classname")[FREEZE return values...] e.g.: ("URI")["http://www.google.com/"] ("MyDate")[2013,10,29] ("ImageData::JPEG")["Z3...VlCg=="] For example, the hypothetical C C method might use the objects C and C members to encode the object: sub My::Object::FREEZE { my ($self, $serializer) = @_; ($self->{type}, $self->{id}) } =item 2. C is enabled and the object has a C method. In this case, the C method of the object is invoked in scalar context. It must return a single scalar that can be directly encoded into JSON. This scalar replaces the object in the JSON text. For example, the following C method will convert all L objects to JSON strings when serialized. The fact that these values originally were L objects is lost. sub URI::TO_JSON { my ($uri) = @_; $uri->as_string } =item 3. C is enabled and the object has a stringification overload. In this case, the overloaded C<""> method of the object is invoked in scalar context. It must return a single scalar that can be directly encoded into JSON. This scalar replaces the object in the JSON text. For example, the following C<""> method will convert all L objects to JSON strings when serialized. The fact that these values originally were L objects is lost. package URI; use overload '""' => sub { shift->as_string }; =item 4. C is enabled. The object will be serialized as a JSON null value. =item 5. none of the above If none of the settings are enabled or the respective methods are missing, C throws an exception. =back =head3 DESERIALIZATION For deserialization there are only two cases to consider: either nonstandard tagging was used, in which case C decides, or objects cannot be automatically be deserialized, in which case you can use postprocessing or the C or C callbacks to get some real objects our of your JSON. This section only considers the tagged value case: I a tagged JSON object is encountered during decoding and C is disabled, a parse error will result (as if tagged values were not part of the grammar). If C is enabled, C will look up the C method of the package/classname used during serialization (it will not attempt to load the package as a Perl module). If there is no such method, the decoding will fail with an error. Otherwise, the C method is invoked with the classname as first argument, the constant string C as second argument, and all the values from the JSON array (the values originally returned by the C method) as remaining arguments. The method must then return the object. While technically you can return any Perl scalar, you might have to enable the C setting to make that work in all cases, so better return an actual blessed reference. As an example, let's implement a C function that regenerates the C from the C example earlier: sub My::Object::THAW { my ($class, $serializer, $type, $id) = @_; $class->new (type => $type, id => $id) } See the L section below. Allowing external json objects being deserialized to perl objects is usually a very bad idea. =head1 ENCODING/CODESET FLAG NOTES The interested reader might have seen a number of flags that signify encodings or codesets - C, C, C and C. There seems to be some confusion on what these do, so here is a short comparison: C controls whether the JSON text created by C (and expected by C) is UTF-8 encoded or not, while C and C only control whether C escapes character values outside their respective codeset range. Neither of these flags conflict with each other, although some combinations make less sense than others. Care has been taken to make all flags symmetrical with respect to C and C, that is, texts encoded with any combination of these flag values will be correctly decoded when the same flags are used - in general, if you use different flag settings while encoding vs. when decoding you likely have a bug somewhere. Below comes a verbose discussion of these flags. Note that a "codeset" is simply an abstract set of character-codepoint pairs, while an encoding takes those codepoint numbers and I them, in our case into octets. Unicode is (among other things) a codeset, UTF-8 is an encoding, and ISO-8859-1 (= latin 1) and ASCII are both codesets I encodings at the same time, which can be confusing. =over 4 =item C flag disabled When C is disabled (the default), then C/C generate and expect Unicode strings, that is, characters with high ordinal Unicode values (> 255) will be encoded as such characters, and likewise such characters are decoded as-is, no changes to them will be done, except "(re-)interpreting" them as Unicode codepoints or Unicode characters, respectively (to Perl, these are the same thing in strings unless you do funny/weird/dumb stuff). This is useful when you want to do the encoding yourself (e.g. when you want to have UTF-16 encoded JSON texts) or when some other layer does the encoding for you (for example, when printing to a terminal using a filehandle that transparently encodes to UTF-8 you certainly do NOT want to UTF-8 encode your data first and have Perl encode it another time). =item C flag enabled If the C-flag is enabled, C/C will encode all characters using the corresponding UTF-8 multi-byte sequence, and will expect your input strings to be encoded as UTF-8, that is, no "character" of the input string must have any value > 255, as UTF-8 does not allow that. The C flag therefore switches between two modes: disabled means you will get a Unicode string in Perl, enabled means you get an UTF-8 encoded octet/binary string in Perl. =item C, C or C flags enabled With C (or C) enabled, C will escape characters with ordinal values > 255 (> 127 with C) and encode the remaining characters as specified by the C flag. With C enabled, ordinal values > 255 are illegal. If C is disabled, then the result is also correctly encoded in those character sets (as both are proper subsets of Unicode, meaning that a Unicode string with all character values < 256 is the same thing as a ISO-8859-1 string, and a Unicode string with all character values < 128 is the same thing as an ASCII string in Perl). If C is enabled, you still get a correct UTF-8-encoded string, regardless of these flags, just some more characters will be escaped using C<\uXXXX> then before. Note that ISO-8859-1-I strings are not compatible with UTF-8 encoding, while ASCII-encoded strings are. That is because the ISO-8859-1 encoding is NOT a subset of UTF-8 (despite the ISO-8859-1 I being a subset of Unicode), while ASCII is. Surprisingly, C will ignore these flags and so treat all input values as governed by the C flag. If it is disabled, this allows you to decode ISO-8859-1- and ASCII-encoded strings, as both strict subsets of Unicode. If it is enabled, you can correctly decode UTF-8 encoded strings. So neither C, C nor C are incompatible with the C flag - they only govern when the JSON output engine escapes a character or not. The main use for C or C is to relatively efficiently store binary data as JSON, at the expense of breaking compatibility with most JSON decoders. The main use for C is to force the output to not contain characters with values > 127, which means you can interpret the resulting string as UTF-8, ISO-8859-1, ASCII, KOI8-R or most about any character set and 8-bit-encoding, and still get the same data structure back. This is useful when your channel for JSON transfer is not 8-bit clean or the encoding might be mangled in between (e.g. in mail), and works because ASCII is a proper subset of most 8-bit and multibyte encodings in use in the world. =back =head2 JSON and ECMAscript JSON syntax is based on how literals are represented in javascript (the not-standardized predecessor of ECMAscript) which is presumably why it is called "JavaScript Object Notation". However, JSON is not a subset (and also not a superset of course) of ECMAscript (the standard) or javascript (whatever browsers actually implement). If you want to use javascript's C function to "parse" JSON, you might run into parse errors for valid JSON texts, or the resulting data structure might not be queryable: One of the problems is that U+2028 and U+2029 are valid characters inside JSON strings, but are not allowed in ECMAscript string literals, so the following Perl fragment will not output something that can be guaranteed to be parsable by javascript's C: use Cpanel::JSON::XS; print encode_json [chr 0x2028]; The right fix for this is to use a proper JSON parser in your javascript programs, and not rely on C (see for example Douglas Crockford's F parser). If this is not an option, you can, as a stop-gap measure, simply encode to ASCII-only JSON: use Cpanel::JSON::XS; print Cpanel::JSON::XS->new->ascii->encode ([chr 0x2028]); Note that this will enlarge the resulting JSON text quite a bit if you have many non-ASCII characters. You might be tempted to run some regexes to only escape U+2028 and U+2029, e.g.: # DO NOT USE THIS! my $json = Cpanel::JSON::XS->new->utf8->encode ([chr 0x2028]); $json =~ s/\xe2\x80\xa8/\\u2028/g; # escape U+2028 $json =~ s/\xe2\x80\xa9/\\u2029/g; # escape U+2029 print $json; Note that I: the above only works for U+2028 and U+2029 and thus only for fully ECMAscript-compliant parsers. Many existing javascript implementations, however, have issues with other characters as well - using C naively simply I cause problems. Another problem is that some javascript implementations reserve some property names for their own purposes (which probably makes them non-ECMAscript-compliant). For example, Iceweasel reserves the C<__proto__> property name for its own purposes. If that is a problem, you could parse try to filter the resulting JSON output for these property strings, e.g.: $json =~ s/"__proto__"\s*:/"__proto__renamed":/g; This works because C<__proto__> is not valid outside of strings, so every occurrence of C<"__proto__"\s*:> must be a string used as property name. Raw non-Unicode characters outside the valid unicode range fail now to parse, because "A string is a sequence of zero or more Unicode characters" RFC 7159 section 1 and "JSON text SHALL be encoded in Unicode RFC 7159 section 8.1. We use now the UTF8_DISALLOW_SUPER flag when parsing unicode. Since RFC 3629, U+D800 through U+DFFF are not legal Unicode values and their UTF-8 encodings must be treated as an invalid byte sequence. RFC 8259 section 8.2 admits the spec allows string values that contain bit sequences that cannot encode Unicode characters and that the behavior of software that receives such values is unpredictable. To avoid introducing non-Unicode strings into Perl we use the UTF8_DISALLOW_SURROGATE flag when parsing Unicode and verify escaped surrogates form valid pairs. If you know of other incompatibilities, please let me know. =head2 JSON and YAML You often hear that JSON is a subset of YAML. I that works in all cases. If you really must use Cpanel::JSON::XS to generate YAML, you should use this algorithm (subject to change in future versions): my $to_yaml = Cpanel::JSON::XS->new->utf8->space_after (1); my $yaml = $to_yaml->encode ($ref) . "\n"; This will I generate JSON texts that also parse as valid YAML. =head2 SPEED It seems that JSON::XS is surprisingly fast, as shown in the following tables. They have been generated with the help of the C program in the JSON::XS distribution, to make it easy to compare on your own system. JSON::XS is with L and L one of the fastest serializers, because JSON and JSON::XS do not support backrefs (no graph structures), only trees. Storable supports backrefs, i.e. graphs. Data::MessagePack encodes its data binary (as Storable) and supports only very simple subset of JSON. First comes a comparison between various modules using a very short single-line JSON string (also available at L). {"method": "handleMessage", "params": ["user1", "we were just talking"], "id": null, "array":[1,11,234,-5,1e5,1e7, 1, 0]} It shows the number of encodes/decodes per second (JSON::XS uses the functional interface, while Cpanel::JSON::XS/2 uses the OO interface with pretty-printing and hash key sorting enabled, Cpanel::JSON::XS/3 enables shrink. JSON::DWIW/DS uses the deserialize function, while JSON::DWIW::FJ uses the from_json method). Higher is better: module | encode | decode | --------------|------------|------------| JSON::DWIW/DS | 86302.551 | 102300.098 | JSON::DWIW/FJ | 86302.551 | 75983.768 | JSON::PP | 15827.562 | 6638.658 | JSON::Syck | 63358.066 | 47662.545 | JSON::XS | 511500.488 | 511500.488 | JSON::XS/2 | 291271.111 | 388361.481 | JSON::XS/3 | 361577.931 | 361577.931 | Storable | 66788.280 | 265462.278 | --------------+------------+------------+ That is, JSON::XS is almost six times faster than JSON::DWIW on encoding, about five times faster on decoding, and over thirty to seventy times faster than JSON's pure perl implementation. It also compares favourably to Storable for small amounts of data. Using a longer test string (roughly 18KB, generated from Yahoo! Locals search API (L). module | encode | decode | --------------|------------|------------| JSON::DWIW/DS | 1647.927 | 2673.916 | JSON::DWIW/FJ | 1630.249 | 2596.128 | JSON::PP | 400.640 | 62.311 | JSON::Syck | 1481.040 | 1524.869 | JSON::XS | 20661.596 | 9541.183 | JSON::XS/2 | 10683.403 | 9416.938 | JSON::XS/3 | 20661.596 | 9400.054 | Storable | 19765.806 | 10000.725 | --------------+------------+------------+ Again, JSON::XS leads by far (except for Storable which non-surprisingly decodes a bit faster). On large strings containing lots of high Unicode characters, some modules (such as JSON::PC) seem to decode faster than JSON::XS, but the result will be broken due to missing (or wrong) Unicode handling. Others refuse to decode or encode properly, so it was impossible to prepare a fair comparison table for that case. For updated graphs see L =head1 INTEROP with JSON and JSON::XS and other JSON modules As long as you only serialize data that can be directly expressed in JSON, C is incapable of generating invalid JSON output (modulo bugs, but C has found more bugs in the official JSON testsuite (1) than the official JSON testsuite has found in C (0)). C is currently the only known JSON decoder which passes all L tests, while being the fastest also. When you have trouble decoding JSON generated by this module using other decoders, then it is very likely that you have an encoding mismatch or the other decoder is broken. When decoding, C is strict by default and will likely catch all errors. There are currently two settings that change this: C makes C accept (but not generate) some non-standard extensions, and C or C will allow you to encode and decode Perl objects, at the cost of being totally insecure and not outputting valid JSON anymore. JSON-XS-3.01 broke interoperability with JSON-2.90 with booleans. See L. Cpanel::JSON::XS needs to know the JSON and JSON::XS versions to be able work with those objects, especially when encoding a booleans like C<{"is_true":true}>. So you need to load these modules before. true/false overloading and boolean representations are supported. JSON::XS and JSON::PP representations are accepted and older JSON::XS accepts Cpanel::JSON::XS booleans. All JSON modules JSON, JSON, PP, JSON::XS, Cpanel::JSON::XS produce JSON::PP::Boolean objects, just Mojo and JSON::YAJL not. Mojo produces Mojo::JSON::_Bool and JSON::YAJL::Parser just an unblessed IV. Cpanel::JSON::XS accepts JSON::PP::Boolean and Mojo::JSON::_Bool objects as booleans. I cannot think of any reason to still use JSON::XS anymore. =head2 TAGGED VALUE SYNTAX AND STANDARD JSON EN/DECODERS When you use C to use the extended (and also nonstandard and invalid) JSON syntax for serialized objects, and you still want to decode the generated serialize objects, you can run a regex to replace the tagged syntax by standard JSON arrays (it only works for "normal" package names without comma, newlines or single colons). First, the readable Perl version: # if your FREEZE methods return no values, you need this replace first: $json =~ s/\( \s* (" (?: [^\\":,]+|\\.|::)* ") \s* \) \s* \[\s*\]/[$1]/gx; # this works for non-empty constructor arg lists: $json =~ s/\( \s* (" (?: [^\\":,]+|\\.|::)* ") \s* \) \s* \[/[$1,/gx; And here is a less readable version that is easy to adapt to other languages: $json =~ s/\(\s*("([^\\":,]+|\\.|::)*")\s*\)\s*\[/[$1,/g; Here is an ECMAScript version (same regex): json = json.replace (/\(\s*("([^\\":,]+|\\.|::)*")\s*\)\s*\[/g, "[$1,"); Since this syntax converts to standard JSON arrays, it might be hard to distinguish serialized objects from normal arrays. You can prepend a "magic number" as first array element to reduce chances of a collision: $json =~ s/\(\s*("([^\\":,]+|\\.|::)*")\s*\)\s*\[/["XU1peReLzT4ggEllLanBYq4G9VzliwKF",$1,/g; And after decoding the JSON text, you could walk the data structure looking for arrays with a first element of C. The same approach can be used to create the tagged format with another encoder. First, you create an array with the magic string as first member, the classname as second, and constructor arguments last, encode it as part of your JSON structure, and then: $json =~ s/\[\s*"XU1peReLzT4ggEllLanBYq4G9VzliwKF"\s*,\s*("([^\\":,]+|\\.|::)*")\s*,/($1)[/g; Again, this has some limitations - the magic string must not be encoded with character escapes, and the constructor arguments must be non-empty. =head1 RFC7159 Since this module was written, Google has written a new JSON RFC, RFC 7159 (and RFC7158). Unfortunately, this RFC breaks compatibility with both the original JSON specification on www.json.org and RFC4627. As far as I can see, you can get partial compatibility when parsing by using C<< ->allow_nonref >>. However, consider the security implications of doing so. I haven't decided yet when to break compatibility with RFC4627 by default (and potentially leave applications insecure) and change the default to follow RFC7159, but application authors are well advised to call C<< ->allow_nonref(0) >> even if this is the current default, if they cannot handle non-reference values, in preparation for the day when the default will change. =head1 SECURITY CONSIDERATIONS JSON::XS and Cpanel::JSON::XS are not only fast. JSON is generally the most secure serializing format, because it is the only one besides Data::MessagePack, which does not deserialize objects per default. For all languages, not just perl. The binary variant BSON (MongoDB) does more but is unsafe. It is trivial for any attacker to create such serialized objects in JSON and trick perl into expanding them, thereby triggering certain methods. Watch L for an exploit demo for "CVE-2015-1592 SixApart MovableType Storable Perl Code Execution" for a deserializer which expands objects. Deserializing even coderefs (methods, functions) or external data would be considered the most dangerous. Security relevant overview of serializers regarding deserializing objects by default: Objects Coderefs External Data Data::Dumper YES YES YES Storable YES NO (def) NO Sereal YES NO NO YAML YES NO NO B::C YES YES YES B::Bytecode YES YES YES BSON YES YES NO JSON::SL YES NO YES JSON NO (def) NO NO Data::MessagePack NO NO NO XML NO NO YES Pickle YES YES YES PHP Deserialize YES NO NO When you are using JSON in a protocol, talking to untrusted potentially hostile creatures requires relatively few measures. First of all, your JSON decoder should be secure, that is, should not have any buffer overflows. Obviously, this module should ensure that. Second, you need to avoid resource-starving attacks. That means you should limit the size of JSON texts you accept, or make sure then when your resources run out, that's just fine (e.g. by using a separate process that can crash safely). The size of a JSON text in octets or characters is usually a good indication of the size of the resources required to decode it into a Perl structure. While JSON::XS can check the size of the JSON text, it might be too late when you already have it in memory, so you might want to check the size before you accept the string. Third, Cpanel::JSON::XS recurses using the C stack when decoding objects and arrays. The C stack is a limited resource: for instance, on my amd64 machine with 8MB of stack size I can decode around 180k nested arrays but only 14k nested JSON objects (due to perl itself recursing deeply on croak to free the temporary). If that is exceeded, the program crashes. To be conservative, the default nesting limit is set to 512. If your process has a smaller stack, you should adjust this setting accordingly with the C method. Also keep in mind that Cpanel::JSON::XS might leak contents of your Perl data structures in its error messages, so when you serialize sensitive information you might want to make sure that exceptions thrown by JSON::XS will not end up in front of untrusted eyes. If you are using Cpanel::JSON::XS to return packets to consumption by JavaScript scripts in a browser you should have a look at L to see whether you are vulnerable to some common attack vectors (which really are browser design bugs, but it is still you who will have to deal with it, as major browser developers care only for features, not about getting security right). You might also want to also look at L special escape rules to prevent from XSS attacks. =head1 "OLD" VS. "NEW" JSON (RFC 4627 VS. RFC 7159) TL;DR: Due to security concerns, Cpanel::JSON::XS will not allow scalar data in JSON texts by default - you need to create your own Cpanel::JSON::XS object and enable C: my $json = JSON::XS->new->allow_nonref; $text = $json->encode ($data); $data = $json->decode ($text); The long version: JSON being an important and supposedly stable format, the IETF standardized it as RFC 4627 in 2006. Unfortunately the inventor of JSON Douglas Crockford unilaterally changed the definition of JSON in javascript. Rather than create a fork, the IETF decided to standardize the new syntax (apparently, so I as told, without finding it very amusing). The biggest difference between the original JSON and the new JSON is that the new JSON supports scalars (anything other than arrays and objects) at the top-level of a JSON text. While this is strictly backwards compatible to older versions, it breaks a number of protocols that relied on sending JSON back-to-back, and is a minor security concern. For example, imagine you have two banks communicating, and on one side, the JSON coder gets upgraded. Two messages, such as C<10> and C<1000> might then be confused to mean C<101000>, something that couldn't happen in the original JSON, because neither of these messages would be valid JSON. If one side accepts these messages, then an upgrade in the coder on either side could result in this becoming exploitable. This module has always allowed these messages as an optional extension, by default disabled. The security concerns are the reason why the default is still disabled, but future versions might/will likely upgrade to the newer RFC as default format, so you are advised to check your implementation and/or override the default with C<< ->allow_nonref (0) >> to ensure that future versions are safe. =head1 THREADS Cpanel::JSON::XS has proper ithreads support, unlike JSON::XS. If you encounter any bugs with thread support please report them. From Version 4.00 - 4.19 you couldn't encode true with threads::shared magic. =head1 BUGS While the goal of the Cpanel::JSON::XS module is to be correct, that unfortunately does not mean it's bug-free, only that the author thinks its design is bug-free. If you keep reporting bugs and tests they will be fixed swiftly, though. Since the JSON::XS author refuses to use a public bugtracker and prefers private emails, we use the tracker at B, so you might want to report any issues twice. Once in private to MLEHMANN to be fixed in JSON::XS and one to our the public tracker. Issues fixed by JSON::XS with a new release will also be backported to Cpanel::JSON::XS and 5.6.2, as long as cPanel relies on 5.6.2 and Cpanel::JSON::XS as our serializer of choice. L =head1 LICENSE This module is available under the same licences as perl, the Artistic license and the GPL. =cut sub allow_bigint { Carp::carp("allow_bigint() is obsoleted. use allow_bignum() instead."); } BEGIN { package JSON::PP::Boolean; require overload; local $^W; # silence redefine warnings. no warnings 'redefine' does not help # These already come with JSON::PP::Boolean. Avoid redefine warning. if (!defined $JSON::PP::Boolean::VERSION or $JSON::PP::VERSION lt '4.00') { &overload::unimport( 'overload', '0+', '++', '--' ); &overload::import( 'overload', "0+" => sub { ${$_[0]} }, "++" => sub { $_[0] = ${$_[0]} + 1 }, "--" => sub { $_[0] = ${$_[0]} - 1 }, ); } # workaround 5.6 reserved keyword warning &overload::unimport( 'overload', '""', 'eq', 'ne' ); &overload::import( 'overload', '""' => sub { ${$_[0]} == 1 ? '1' : '0' }, # GH 29 'eq' => sub { my ($obj, $op) = $_[2] ? ($_[1], $_[0]) : ($_[0], $_[1]); #warn "eq obj:$obj op:$op len:", length($op) > 0, " swap:$_[2]"; if (ref $op) { # if 2nd also blessed might recurse endlessly return $obj ? 1 == $op : 0 == $op; } # if string, only accept numbers or true|false or "" (e.g. !!0 / SV_NO) elsif ($op !~ /^[0-9]+$/) { return "$obj" eq '1' ? 'true' eq $op : 'false' eq $op || "" eq $op; } else { return $obj ? 1 == $op : 0 == $op; } }, 'ne' => sub { my ($obj, $op) = $_[2] ? ($_[1], $_[0]) : ($_[0], $_[1]); #warn "ne obj:$obj op:$op"; return !($obj eq $op); }, fallback => 1); } our ($true, $false); BEGIN { if ($INC{'JSON/XS.pm'} and $INC{'Types/Serialiser.pm'} and $JSON::XS::VERSION ge "3.00") { $true = $Types::Serialiser::true; # readonly if loaded by JSON::XS $false = $Types::Serialiser::false; } else { $true = do { bless \(my $dummy = 1), "JSON::PP::Boolean" }; $false = do { bless \(my $dummy = 0), "JSON::PP::Boolean" }; } } BEGIN { my $const_true = $true; my $const_false = $false; *true = sub () { $const_true }; *false = sub () { $const_false }; } sub is_bool($) { shift if @_ == 2; # as method call (ref($_[0]) and UNIVERSAL::isa( $_[0], JSON::PP::Boolean::)) or (exists $INC{'Types/Serialiser.pm'} and Types::Serialiser::is_bool($_[0])) } XSLoader::load 'Cpanel::JSON::XS', $XS_VERSION; 1; =head1 SEE ALSO The F command line utility for quick experiments. L, L, L, L, L, L, L, L, L, L, L, L, L L L =head1 AUTHOR Reini Urban Marc Lehmann , http://home.schmorp.de/ =head1 MAINTAINER Reini Urban =cut Syck.pm000044400000015717152344454660006041 0ustar00package JSON::Syck; use strict; use Exporter; use YAML::Syck (); our $VERSION = '1.47'; our @EXPORT_OK = qw( Load Dump LoadFile DumpFile DumpInto ); our @ISA = qw/Exporter/; *Load = \&YAML::Syck::LoadJSON; *Dump = \&YAML::Syck::DumpJSON; sub DumpFile { my $file = shift; if ( YAML::Syck::_is_glob($file) ) { if ( tied(*$file) ) { # Tied filehandles (IO::String, IO::Scalar, etc.) don't support # C-level PerlIO_write. Fall back to Perl-level print. print $file YAML::Syck::DumpJSON( $_[0] ) or die "Error writing to filehandle $file: $!\n"; } else { my $err = YAML::Syck::DumpJSONFile( $_[0], $file ); if ($err) { $! = 0 + $err; die "Error writing to filehandle $file: $!\n"; } } } else { open( my $fh, '>', $file ) or die "Cannot write to $file: $!"; my $err = YAML::Syck::DumpJSONFile( $_[0], $fh ); if ($err) { $! = 0 + $err; die "Error writing to file $file: $!\n"; } close $fh or die "Error writing to file $file: $!\n"; } return 1; } sub LoadFile { my $file = shift; if ( YAML::Syck::_is_glob($file) ) { YAML::Syck::LoadJSON( do { local $/; <$file> } ); } else { if ( !-e $file || -z $file ) { die("'$file' is non-existent or empty"); } open( my $fh, '<', $file ) or die "Cannot read from $file: $!"; YAML::Syck::LoadJSON( do { local $/; <$fh> } ); } } sub DumpInto { my $bufref = shift; ( ref $bufref ) or die "DumpInto not given reference to output buffer\n"; YAML::Syck::DumpJSONInto( $_[0], $bufref ); 1; } $JSON::Syck::ImplicitTyping = 1; $JSON::Syck::MaxDepth = 512; $JSON::Syck::Headless = 1; $JSON::Syck::ImplicitUnicode = 0; $JSON::Syck::SingleQuote = 0; 1; __END__ =head1 NAME JSON::Syck - JSON is YAML (but consider using L instead!) =head1 SYNOPSIS use JSON::Syck; # no exports by default my $data = JSON::Syck::Load($json); my $json = JSON::Syck::Dump($data); # $file can be an IO object, or a filename my $data = JSON::Syck::LoadFile($file); JSON::Syck::DumpFile($file, $data); # Dump into a pre-existing buffer my $json; JSON::Syck::DumpInto(\$json, $data); =head1 DESCRIPTION JSON::Syck is a syck implementation of JSON parsing and generation. Because JSON is YAML (L), using syck gives you a fast and memory-efficient parser and dumper for JSON data representation. However, a newer module L, has since emerged. It is more flexible, efficient and robust, so please consider using it instead of this module. =head1 DIFFERENCE WITH JSON You might want to know the difference between the I module and this one. 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 L JSON.pm comes with dozens of ways to do the same thing and lots of options, while JSON::Syck doesn't. There's only C and C. Oh, and JSON::Syck doesn't use camelCase method names :-) =head1 REFERENCES =head2 SCALAR REFERENCE 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 referencing stuff, you should use YAML which supports it. =head2 SUBROUTINE REFERENCE When you pass subroutine reference, JSON::Syck dumps it as null. =head1 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 C<$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) By default, JSON::Syck::Dump will only transverse up to 512 levels of a datastructure in order to avoid an infinite loop when it is presented with an circular reference. However, you can set C<$JSON::Syck::MaxDepth> to a larger value if you have very complex structures. 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 I<%uXXXX> form. use Encode; use Encode::JavaScript::UCS; use JSON::Syck qw(Dump); my $json_unicode_escaped = encode( 'JavaScript-UCS', Dump($data) ); =head1 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 C<$JSON::Syck::SingleQuote> to 1 will make both C and C expect single-quoted string literals. =head1 BUGS Dumping into tied (or other magic variables) with C might not work properly in all cases. When dumping with C, spacing differs from C (extra spaces after colons and a trailing newline) because C uses the C-level serializer directly. =head1 SEE ALSO L, L =head1 AUTHORS Audrey Tang Ecpan@audreyt.orgE Tatsuhiko Miyagawa Emiyagawa@gmail.comE =head1 COPYRIGHT Copyright 2005-2009 by Audrey Tang Ecpan@audreyt.orgE. This software is released under the MIT license cited below. The F code bundled with this library is released by "why the lucky stiff", under a BSD-style license. See the F file for details. =head2 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. =cut XS/Boolean.pm000044400000000726152344454660007033 0ustar00=head1 NAME Cpanel::JSON::XS::Boolean - true and false values =head1 SYNOPSIS # do not "use" yourself See L =head1 DESCRIPTION This module exists only to provide overload resolution for Storable and similar modules and interop with L booleans. See L for more info about this class. =cut use Cpanel::JSON::XS (); 1; =head1 AUTHOR Marc Lehmann http://home.schmorp.de/ =cut PP/Boolean.pm000064400000001204152344456660007014 0ustar00package JSON::PP::Boolean; use strict; use overload ( "0+" => sub { ${$_[0]} }, "++" => sub { $_[0] = ${$_[0]} + 1 }, "--" => sub { $_[0] = ${$_[0]} - 1 }, fallback => 1, ); $JSON::PP::Boolean::VERSION = '2.97001'; 1; __END__ =head1 NAME JSON::PP::Boolean - dummy module providing JSON::PP::Boolean =head1 SYNOPSIS # do not "use" yourself =head1 DESCRIPTION This module exists only to provide overload resolution for Storable and similar modules. See L for more info about this class. =head1 AUTHOR This idea is from L written by Marc Lehmann =cut PP.pm000064400000257155152344456660005457 0ustar00package JSON::PP; # JSON-2.0 use 5.005; use strict; use Exporter (); BEGIN { @JSON::PP::ISA = ('Exporter') } use overload (); use JSON::PP::Boolean; use Carp (); #use Devel::Peek; $JSON::PP::VERSION = '2.97001'; @JSON::PP::EXPORT = qw(encode_json decode_json from_json to_json); # instead of hash-access, i tried index-access for speed. # but this method is not faster than what i expected. so it will be changed. use constant P_ASCII => 0; use constant P_LATIN1 => 1; use constant P_UTF8 => 2; use constant P_INDENT => 3; use constant P_CANONICAL => 4; use constant P_SPACE_BEFORE => 5; use constant P_SPACE_AFTER => 6; use constant P_ALLOW_NONREF => 7; use constant P_SHRINK => 8; use constant P_ALLOW_BLESSED => 9; use constant P_CONVERT_BLESSED => 10; use constant P_RELAXED => 11; use constant P_LOOSE => 12; use constant P_ALLOW_BIGNUM => 13; use constant P_ALLOW_BAREKEY => 14; use constant P_ALLOW_SINGLEQUOTE => 15; use constant P_ESCAPE_SLASH => 16; use constant P_AS_NONBLESSED => 17; use constant P_ALLOW_UNKNOWN => 18; use constant OLD_PERL => $] < 5.008 ? 1 : 0; use constant USE_B => 0; BEGIN { if (USE_B) { require B; } } BEGIN { my @xs_compati_bit_properties = qw( latin1 ascii utf8 indent canonical space_before space_after allow_nonref shrink allow_blessed convert_blessed relaxed allow_unknown ); my @pp_bit_properties = qw( allow_singlequote allow_bignum loose allow_barekey escape_slash as_nonblessed ); # Perl version check, Unicode handling is enabled? # Helper module sets @JSON::PP::_properties. if ( OLD_PERL ) { my $helper = $] >= 5.006 ? 'JSON::PP::Compat5006' : 'JSON::PP::Compat5005'; eval qq| require $helper |; if ($@) { Carp::croak $@; } } for my $name (@xs_compati_bit_properties, @pp_bit_properties) { my $property_id = 'P_' . uc($name); eval qq/ sub $name { my \$enable = defined \$_[1] ? \$_[1] : 1; if (\$enable) { \$_[0]->{PROPS}->[$property_id] = 1; } else { \$_[0]->{PROPS}->[$property_id] = 0; } \$_[0]; } sub get_$name { \$_[0]->{PROPS}->[$property_id] ? 1 : ''; } /; } } # Functions my $JSON; # cache sub encode_json ($) { # encode ($JSON ||= __PACKAGE__->new->utf8)->encode(@_); } sub decode_json { # decode ($JSON ||= __PACKAGE__->new->utf8)->decode(@_); } # Obsoleted sub to_json($) { Carp::croak ("JSON::PP::to_json has been renamed to encode_json."); } sub from_json($) { Carp::croak ("JSON::PP::from_json has been renamed to decode_json."); } # Methods sub new { my $class = shift; my $self = { max_depth => 512, max_size => 0, indent_length => 3, }; bless $self, $class; } sub encode { return $_[0]->PP_encode_json($_[1]); } sub decode { return $_[0]->PP_decode_json($_[1], 0x00000000); } sub decode_prefix { return $_[0]->PP_decode_json($_[1], 0x00000001); } # accessor # pretty printing sub pretty { my ($self, $v) = @_; my $enable = defined $v ? $v : 1; if ($enable) { # indent_length(3) for JSON::XS compatibility $self->indent(1)->space_before(1)->space_after(1); } else { $self->indent(0)->space_before(0)->space_after(0); } $self; } # etc sub max_depth { my $max = defined $_[1] ? $_[1] : 0x80000000; $_[0]->{max_depth} = $max; $_[0]; } sub get_max_depth { $_[0]->{max_depth}; } sub max_size { my $max = defined $_[1] ? $_[1] : 0; $_[0]->{max_size} = $max; $_[0]; } sub get_max_size { $_[0]->{max_size}; } sub filter_json_object { if (defined $_[1] and ref $_[1] eq 'CODE') { $_[0]->{cb_object} = $_[1]; } else { delete $_[0]->{cb_object}; } $_[0]->{F_HOOK} = ($_[0]->{cb_object} or $_[0]->{cb_sk_object}) ? 1 : 0; $_[0]; } sub filter_json_single_key_object { if (@_ == 1 or @_ > 3) { Carp::croak("Usage: JSON::PP::filter_json_single_key_object(self, key, callback = undef)"); } if (defined $_[2] and ref $_[2] eq 'CODE') { $_[0]->{cb_sk_object}->{$_[1]} = $_[2]; } else { delete $_[0]->{cb_sk_object}->{$_[1]}; delete $_[0]->{cb_sk_object} unless %{$_[0]->{cb_sk_object} || {}}; } $_[0]->{F_HOOK} = ($_[0]->{cb_object} or $_[0]->{cb_sk_object}) ? 1 : 0; $_[0]; } sub indent_length { if (!defined $_[1] or $_[1] > 15 or $_[1] < 0) { Carp::carp "The acceptable range of indent_length() is 0 to 15."; } else { $_[0]->{indent_length} = $_[1]; } $_[0]; } sub get_indent_length { $_[0]->{indent_length}; } sub sort_by { $_[0]->{sort_by} = defined $_[1] ? $_[1] : 1; $_[0]; } sub allow_bigint { Carp::carp("allow_bigint() is obsoleted. use allow_bignum() instead."); $_[0]->allow_bignum; } ############################### ### ### Perl => JSON ### { # Convert my $max_depth; my $indent; my $ascii; my $latin1; my $utf8; my $space_before; my $space_after; my $canonical; my $allow_blessed; my $convert_blessed; my $indent_length; my $escape_slash; my $bignum; my $as_nonblessed; my $depth; my $indent_count; my $keysort; sub PP_encode_json { my $self = shift; my $obj = shift; $indent_count = 0; $depth = 0; my $props = $self->{PROPS}; ($ascii, $latin1, $utf8, $indent, $canonical, $space_before, $space_after, $allow_blessed, $convert_blessed, $escape_slash, $bignum, $as_nonblessed) = @{$props}[P_ASCII .. P_SPACE_AFTER, P_ALLOW_BLESSED, P_CONVERT_BLESSED, P_ESCAPE_SLASH, P_ALLOW_BIGNUM, P_AS_NONBLESSED]; ($max_depth, $indent_length) = @{$self}{qw/max_depth indent_length/}; $keysort = $canonical ? sub { $a cmp $b } : undef; if ($self->{sort_by}) { $keysort = ref($self->{sort_by}) eq 'CODE' ? $self->{sort_by} : $self->{sort_by} =~ /\D+/ ? $self->{sort_by} : sub { $a cmp $b }; } encode_error("hash- or arrayref expected (not a simple scalar, use allow_nonref to allow this)") if(!ref $obj and !$props->[ P_ALLOW_NONREF ]); my $str = $self->object_to_json($obj); $str .= "\n" if ( $indent ); # JSON::XS 2.26 compatible unless ($ascii or $latin1 or $utf8) { utf8::upgrade($str); } if ($props->[ P_SHRINK ]) { utf8::downgrade($str, 1); } return $str; } sub object_to_json { my ($self, $obj) = @_; my $type = ref($obj); if($type eq 'HASH'){ return $self->hash_to_json($obj); } elsif($type eq 'ARRAY'){ return $self->array_to_json($obj); } elsif ($type) { # blessed object? if (blessed($obj)) { return $self->value_to_json($obj) if ( $obj->isa('JSON::PP::Boolean') ); if ( $convert_blessed and $obj->can('TO_JSON') ) { my $result = $obj->TO_JSON(); if ( defined $result and ref( $result ) ) { if ( refaddr( $obj ) eq refaddr( $result ) ) { encode_error( sprintf( "%s::TO_JSON method returned same object as was passed instead of a new one", ref $obj ) ); } } return $self->object_to_json( $result ); } return "$obj" if ( $bignum and _is_bignum($obj) ); if ($allow_blessed) { return $self->blessed_to_json($obj) if ($as_nonblessed); # will be removed. return 'null'; } encode_error( sprintf("encountered object '%s', but neither allow_blessed " . "nor convert_blessed settings are enabled", $obj) ); } else { return $self->value_to_json($obj); } } else{ return $self->value_to_json($obj); } } sub hash_to_json { my ($self, $obj) = @_; my @res; encode_error("json text or perl structure exceeds maximum nesting level (max_depth set too low?)") if (++$depth > $max_depth); my ($pre, $post) = $indent ? $self->_up_indent() : ('', ''); my $del = ($space_before ? ' ' : '') . ':' . ($space_after ? ' ' : ''); for my $k ( _sort( $obj ) ) { if ( OLD_PERL ) { utf8::decode($k) } # key for Perl 5.6 / be optimized push @res, $self->string_to_json( $k ) . $del . ( ref $obj->{$k} ? $self->object_to_json( $obj->{$k} ) : $self->value_to_json( $obj->{$k} ) ); } --$depth; $self->_down_indent() if ($indent); return '{}' unless @res; return '{' . $pre . join( ",$pre", @res ) . $post . '}'; } sub array_to_json { my ($self, $obj) = @_; my @res; encode_error("json text or perl structure exceeds maximum nesting level (max_depth set too low?)") if (++$depth > $max_depth); my ($pre, $post) = $indent ? $self->_up_indent() : ('', ''); for my $v (@$obj){ push @res, ref($v) ? $self->object_to_json($v) : $self->value_to_json($v); } --$depth; $self->_down_indent() if ($indent); return '[]' unless @res; return '[' . $pre . join( ",$pre", @res ) . $post . ']'; } sub _looks_like_number { my $value = shift; if (USE_B) { my $b_obj = B::svref_2object(\$value); my $flags = $b_obj->FLAGS; return 1 if $flags & ( B::SVp_IOK() | B::SVp_NOK() ) and !( $flags & B::SVp_POK() ); return; } else { no warnings 'numeric'; # if the utf8 flag is on, it almost certainly started as a string return if utf8::is_utf8($value); # detect numbers # string & "" -> "" # number & "" -> 0 (with warning) # nan and inf can detect as numbers, so check with * 0 return unless length((my $dummy = "") & $value); return unless 0 + $value eq $value; return 1 if $value * 0 == 0; return -1; # inf/nan } } sub value_to_json { my ($self, $value) = @_; return 'null' if(!defined $value); my $type = ref($value); if (!$type) { if (_looks_like_number($value)) { return $value; } return $self->string_to_json($value); } elsif( blessed($value) and $value->isa('JSON::PP::Boolean') ){ return $$value == 1 ? 'true' : 'false'; } else { if ((overload::StrVal($value) =~ /=(\w+)/)[0]) { return $self->value_to_json("$value"); } if ($type eq 'SCALAR' and defined $$value) { return $$value eq '1' ? 'true' : $$value eq '0' ? 'false' : $self->{PROPS}->[ P_ALLOW_UNKNOWN ] ? 'null' : encode_error("cannot encode reference to scalar"); } if ( $self->{PROPS}->[ P_ALLOW_UNKNOWN ] ) { return 'null'; } else { if ( $type eq 'SCALAR' or $type eq 'REF' ) { encode_error("cannot encode reference to scalar"); } else { encode_error("encountered $value, but JSON can only represent references to arrays or hashes"); } } } } my %esc = ( "\n" => '\n', "\r" => '\r', "\t" => '\t', "\f" => '\f', "\b" => '\b', "\"" => '\"', "\\" => '\\\\', "\'" => '\\\'', ); sub string_to_json { my ($self, $arg) = @_; $arg =~ s/([\x22\x5c\n\r\t\f\b])/$esc{$1}/g; $arg =~ s/\//\\\//g if ($escape_slash); $arg =~ s/([\x00-\x08\x0b\x0e-\x1f])/'\\u00' . unpack('H2', $1)/eg; if ($ascii) { $arg = JSON_PP_encode_ascii($arg); } if ($latin1) { $arg = JSON_PP_encode_latin1($arg); } if ($utf8) { utf8::encode($arg); } return '"' . $arg . '"'; } sub blessed_to_json { my $reftype = reftype($_[1]) || ''; if ($reftype eq 'HASH') { return $_[0]->hash_to_json($_[1]); } elsif ($reftype eq 'ARRAY') { return $_[0]->array_to_json($_[1]); } else { return 'null'; } } sub encode_error { my $error = shift; Carp::croak "$error"; } sub _sort { defined $keysort ? (sort $keysort (keys %{$_[0]})) : keys %{$_[0]}; } sub _up_indent { my $self = shift; my $space = ' ' x $indent_length; my ($pre,$post) = ('',''); $post = "\n" . $space x $indent_count; $indent_count++; $pre = "\n" . $space x $indent_count; return ($pre,$post); } sub _down_indent { $indent_count--; } sub PP_encode_box { { depth => $depth, indent_count => $indent_count, }; } } # Convert sub _encode_ascii { join('', map { $_ <= 127 ? chr($_) : $_ <= 65535 ? sprintf('\u%04x', $_) : sprintf('\u%x\u%x', _encode_surrogates($_)); } unpack('U*', $_[0]) ); } sub _encode_latin1 { join('', map { $_ <= 255 ? chr($_) : $_ <= 65535 ? sprintf('\u%04x', $_) : sprintf('\u%x\u%x', _encode_surrogates($_)); } unpack('U*', $_[0]) ); } sub _encode_surrogates { # from perlunicode my $uni = $_[0] - 0x10000; return ($uni / 0x400 + 0xD800, $uni % 0x400 + 0xDC00); } sub _is_bignum { $_[0]->isa('Math::BigInt') or $_[0]->isa('Math::BigFloat'); } # # JSON => Perl # my $max_intsize; BEGIN { my $checkint = 1111; for my $d (5..64) { $checkint .= 1; my $int = eval qq| $checkint |; if ($int =~ /[eE]/) { $max_intsize = $d - 1; last; } } } { # PARSE my %escapes = ( # by Jeremy Muhlich b => "\x8", t => "\x9", n => "\xA", f => "\xC", r => "\xD", '\\' => '\\', '"' => '"', '/' => '/', ); my $text; # json data my $at; # offset my $ch; # first character my $len; # text length (changed according to UTF8 or NON UTF8) # INTERNAL my $depth; # nest counter my $encoding; # json text encoding my $is_valid_utf8; # temp variable my $utf8_len; # utf8 byte length # FLAGS my $utf8; # must be utf8 my $max_depth; # max nest number of objects and arrays my $max_size; my $relaxed; my $cb_object; my $cb_sk_object; my $F_HOOK; my $allow_bignum; # using Math::BigInt/BigFloat my $singlequote; # loosely quoting my $loose; # my $allow_barekey; # bareKey sub _detect_utf_encoding { my $text = shift; my @octets = unpack('C4', $text); return 'unknown' unless defined $octets[3]; return ( $octets[0] and $octets[1]) ? 'UTF-8' : (!$octets[0] and $octets[1]) ? 'UTF-16BE' : (!$octets[0] and !$octets[1]) ? 'UTF-32BE' : ( $octets[2] ) ? 'UTF-16LE' : (!$octets[2] ) ? 'UTF-32LE' : 'unknown'; } sub PP_decode_json { my ($self, $want_offset); ($self, $text, $want_offset) = @_; ($at, $ch, $depth) = (0, '', 0); if ( !defined $text or ref $text ) { decode_error("malformed JSON string, neither array, object, number, string or atom"); } my $props = $self->{PROPS}; ($utf8, $relaxed, $loose, $allow_bignum, $allow_barekey, $singlequote) = @{$props}[P_UTF8, P_RELAXED, P_LOOSE .. P_ALLOW_SINGLEQUOTE]; if ( $utf8 ) { $encoding = _detect_utf_encoding($text); if ($encoding ne 'UTF-8' and $encoding ne 'unknown') { require Encode; Encode::from_to($text, $encoding, 'utf-8'); } else { utf8::downgrade( $text, 1 ) or Carp::croak("Wide character in subroutine entry"); } } else { utf8::upgrade( $text ); utf8::encode( $text ); } $len = length $text; ($max_depth, $max_size, $cb_object, $cb_sk_object, $F_HOOK) = @{$self}{qw/max_depth max_size cb_object cb_sk_object F_HOOK/}; if ($max_size > 1) { use bytes; my $bytes = length $text; decode_error( sprintf("attempted decode of JSON text of %s bytes size, but max_size is set to %s" , $bytes, $max_size), 1 ) if ($bytes > $max_size); } white(); # remove head white space decode_error("malformed JSON string, neither array, object, number, string or atom") unless defined $ch; # Is there a first character for JSON structure? my $result = value(); if ( !$props->[ P_ALLOW_NONREF ] and !ref $result ) { decode_error( 'JSON text must be an object or array (but found number, string, true, false or null,' . ' use allow_nonref to allow this)', 1); } Carp::croak('something wrong.') if $len < $at; # we won't arrive here. my $consumed = defined $ch ? $at - 1 : $at; # consumed JSON text length white(); # remove tail white space return ( $result, $consumed ) if $want_offset; # all right if decode_prefix decode_error("garbage after JSON object") if defined $ch; $result; } sub next_chr { return $ch = undef if($at >= $len); $ch = substr($text, $at++, 1); } sub value { white(); return if(!defined $ch); return object() if($ch eq '{'); return array() if($ch eq '['); return string() if($ch eq '"' or ($singlequote and $ch eq "'")); return number() if($ch =~ /[0-9]/ or $ch eq '-'); return word(); } sub string { my $utf16; my $is_utf8; ($is_valid_utf8, $utf8_len) = ('', 0); my $s = ''; # basically UTF8 flag on if($ch eq '"' or ($singlequote and $ch eq "'")){ my $boundChar = $ch; OUTER: while( defined(next_chr()) ){ if($ch eq $boundChar){ next_chr(); if ($utf16) { decode_error("missing low surrogate character in surrogate pair"); } utf8::decode($s) if($is_utf8); return $s; } elsif($ch eq '\\'){ next_chr(); if(exists $escapes{$ch}){ $s .= $escapes{$ch}; } elsif($ch eq 'u'){ # UNICODE handling my $u = ''; for(1..4){ $ch = next_chr(); last OUTER if($ch !~ /[0-9a-fA-F]/); $u .= $ch; } # U+D800 - U+DBFF if ($u =~ /^[dD][89abAB][0-9a-fA-F]{2}/) { # UTF-16 high surrogate? $utf16 = $u; } # U+DC00 - U+DFFF elsif ($u =~ /^[dD][c-fC-F][0-9a-fA-F]{2}/) { # UTF-16 low surrogate? unless (defined $utf16) { decode_error("missing high surrogate character in surrogate pair"); } $is_utf8 = 1; $s .= JSON_PP_decode_surrogates($utf16, $u) || next; $utf16 = undef; } else { if (defined $utf16) { decode_error("surrogate pair expected"); } if ( ( my $hex = hex( $u ) ) > 127 ) { $is_utf8 = 1; $s .= JSON_PP_decode_unicode($u) || next; } else { $s .= chr $hex; } } } else{ unless ($loose) { $at -= 2; decode_error('illegal backslash escape sequence in string'); } $s .= $ch; } } else{ if ( ord $ch > 127 ) { unless( $ch = is_valid_utf8($ch) ) { $at -= 1; decode_error("malformed UTF-8 character in JSON string"); } else { $at += $utf8_len - 1; } $is_utf8 = 1; } if (!$loose) { if ($ch =~ /[\x00-\x1f\x22\x5c]/) { # '/' ok $at--; decode_error('invalid character encountered while parsing JSON string'); } } $s .= $ch; } } } decode_error("unexpected end of string while parsing JSON string"); } sub white { while( defined $ch ){ if($ch eq '' or $ch =~ /\A[ \t\r\n]\z/){ next_chr(); } elsif($relaxed and $ch eq '/'){ next_chr(); if(defined $ch and $ch eq '/'){ 1 while(defined(next_chr()) and $ch ne "\n" and $ch ne "\r"); } elsif(defined $ch and $ch eq '*'){ next_chr(); while(1){ if(defined $ch){ if($ch eq '*'){ if(defined(next_chr()) and $ch eq '/'){ next_chr(); last; } } else{ next_chr(); } } else{ decode_error("Unterminated comment"); } } next; } else{ $at--; decode_error("malformed JSON string, neither array, object, number, string or atom"); } } else{ if ($relaxed and $ch eq '#') { # correctly? pos($text) = $at; $text =~ /\G([^\n]*(?:\r\n|\r|\n|$))/g; $at = pos($text); next_chr; next; } last; } } } sub array { my $a = $_[0] || []; # you can use this code to use another array ref object. decode_error('json text or perl structure exceeds maximum nesting level (max_depth set too low?)') if (++$depth > $max_depth); next_chr(); white(); if(defined $ch and $ch eq ']'){ --$depth; next_chr(); return $a; } else { while(defined($ch)){ push @$a, value(); white(); if (!defined $ch) { last; } if($ch eq ']'){ --$depth; next_chr(); return $a; } if($ch ne ','){ last; } next_chr(); white(); if ($relaxed and $ch eq ']') { --$depth; next_chr(); return $a; } } } $at-- if defined $ch and $ch ne ''; decode_error(", or ] expected while parsing array"); } sub object { my $o = $_[0] || {}; # you can use this code to use another hash ref object. my $k; decode_error('json text or perl structure exceeds maximum nesting level (max_depth set too low?)') if (++$depth > $max_depth); next_chr(); white(); if(defined $ch and $ch eq '}'){ --$depth; next_chr(); if ($F_HOOK) { return _json_object_hook($o); } return $o; } else { while (defined $ch) { $k = ($allow_barekey and $ch ne '"' and $ch ne "'") ? bareKey() : string(); white(); if(!defined $ch or $ch ne ':'){ $at--; decode_error("':' expected"); } next_chr(); $o->{$k} = value(); white(); last if (!defined $ch); if($ch eq '}'){ --$depth; next_chr(); if ($F_HOOK) { return _json_object_hook($o); } return $o; } if($ch ne ','){ last; } next_chr(); white(); if ($relaxed and $ch eq '}') { --$depth; next_chr(); if ($F_HOOK) { return _json_object_hook($o); } return $o; } } } $at-- if defined $ch and $ch ne ''; decode_error(", or } expected while parsing object/hash"); } sub bareKey { # doesn't strictly follow Standard ECMA-262 3rd Edition my $key; while($ch =~ /[^\x00-\x23\x25-\x2F\x3A-\x40\x5B-\x5E\x60\x7B-\x7F]/){ $key .= $ch; next_chr(); } return $key; } sub word { my $word = substr($text,$at-1,4); if($word eq 'true'){ $at += 3; next_chr; return $JSON::PP::true; } elsif($word eq 'null'){ $at += 3; next_chr; return undef; } elsif($word eq 'fals'){ $at += 3; if(substr($text,$at,1) eq 'e'){ $at++; next_chr; return $JSON::PP::false; } } $at--; # for decode_error report decode_error("'null' expected") if ($word =~ /^n/); decode_error("'true' expected") if ($word =~ /^t/); decode_error("'false' expected") if ($word =~ /^f/); decode_error("malformed JSON string, neither array, object, number, string or atom"); } sub number { my $n = ''; my $v; my $is_dec; my $is_exp; if($ch eq '-'){ $n = '-'; next_chr; if (!defined $ch or $ch !~ /\d/) { decode_error("malformed number (no digits after initial minus)"); } } # According to RFC4627, hex or oct digits are invalid. if($ch eq '0'){ my $peek = substr($text,$at,1); if($peek =~ /^[0-9a-dfA-DF]/){ # e may be valid (exponential) decode_error("malformed number (leading zero must not be followed by another digit)"); } $n .= $ch; next_chr; } while(defined $ch and $ch =~ /\d/){ $n .= $ch; next_chr; } if(defined $ch and $ch eq '.'){ $n .= '.'; $is_dec = 1; next_chr; if (!defined $ch or $ch !~ /\d/) { decode_error("malformed number (no digits after decimal point)"); } else { $n .= $ch; } while(defined(next_chr) and $ch =~ /\d/){ $n .= $ch; } } if(defined $ch and ($ch eq 'e' or $ch eq 'E')){ $n .= $ch; $is_exp = 1; next_chr; if(defined($ch) and ($ch eq '+' or $ch eq '-')){ $n .= $ch; next_chr; if (!defined $ch or $ch =~ /\D/) { decode_error("malformed number (no digits after exp sign)"); } $n .= $ch; } elsif(defined($ch) and $ch =~ /\d/){ $n .= $ch; } else { decode_error("malformed number (no digits after exp sign)"); } while(defined(next_chr) and $ch =~ /\d/){ $n .= $ch; } } $v .= $n; if ($is_dec or $is_exp) { if ($allow_bignum) { require Math::BigFloat; return Math::BigFloat->new($v); } } else { if (length $v > $max_intsize) { if ($allow_bignum) { # from Adam Sussman require Math::BigInt; return Math::BigInt->new($v); } else { return "$v"; } } } return $is_dec ? $v/1.0 : 0+$v; } sub is_valid_utf8 { $utf8_len = $_[0] =~ /[\x00-\x7F]/ ? 1 : $_[0] =~ /[\xC2-\xDF]/ ? 2 : $_[0] =~ /[\xE0-\xEF]/ ? 3 : $_[0] =~ /[\xF0-\xF4]/ ? 4 : 0 ; return unless $utf8_len; my $is_valid_utf8 = substr($text, $at - 1, $utf8_len); return ( $is_valid_utf8 =~ /^(?: [\x00-\x7F] |[\xC2-\xDF][\x80-\xBF] |[\xE0][\xA0-\xBF][\x80-\xBF] |[\xE1-\xEC][\x80-\xBF][\x80-\xBF] |[\xED][\x80-\x9F][\x80-\xBF] |[\xEE-\xEF][\x80-\xBF][\x80-\xBF] |[\xF0][\x90-\xBF][\x80-\xBF][\x80-\xBF] |[\xF1-\xF3][\x80-\xBF][\x80-\xBF][\x80-\xBF] |[\xF4][\x80-\x8F][\x80-\xBF][\x80-\xBF] )$/x ) ? $is_valid_utf8 : ''; } sub decode_error { my $error = shift; my $no_rep = shift; my $str = defined $text ? substr($text, $at) : ''; my $mess = ''; my $type = 'U*'; if ( OLD_PERL ) { my $type = $] < 5.006 ? 'C*' : utf8::is_utf8( $str ) ? 'U*' # 5.6 : 'C*' ; } for my $c ( unpack( $type, $str ) ) { # emulate pv_uni_display() ? $mess .= $c == 0x07 ? '\a' : $c == 0x09 ? '\t' : $c == 0x0a ? '\n' : $c == 0x0d ? '\r' : $c == 0x0c ? '\f' : $c < 0x20 ? sprintf('\x{%x}', $c) : $c == 0x5c ? '\\\\' : $c < 0x80 ? chr($c) : sprintf('\x{%x}', $c) ; if ( length $mess >= 20 ) { $mess .= '...'; last; } } unless ( length $mess ) { $mess = '(end of string)'; } Carp::croak ( $no_rep ? "$error" : "$error, at character offset $at (before \"$mess\")" ); } sub _json_object_hook { my $o = $_[0]; my @ks = keys %{$o}; if ( $cb_sk_object and @ks == 1 and exists $cb_sk_object->{ $ks[0] } and ref $cb_sk_object->{ $ks[0] } ) { my @val = $cb_sk_object->{ $ks[0] }->( $o->{$ks[0]} ); if (@val == 1) { return $val[0]; } } my @val = $cb_object->($o) if ($cb_object); if (@val == 0 or @val > 1) { return $o; } else { return $val[0]; } } sub PP_decode_box { { text => $text, at => $at, ch => $ch, len => $len, depth => $depth, encoding => $encoding, is_valid_utf8 => $is_valid_utf8, }; } } # PARSE sub _decode_surrogates { # from perlunicode my $uni = 0x10000 + (hex($_[0]) - 0xD800) * 0x400 + (hex($_[1]) - 0xDC00); my $un = pack('U*', $uni); utf8::encode( $un ); return $un; } sub _decode_unicode { my $un = pack('U', hex shift); utf8::encode( $un ); return $un; } # # Setup for various Perl versions (the code from JSON::PP58) # BEGIN { unless ( defined &utf8::is_utf8 ) { require Encode; *utf8::is_utf8 = *Encode::is_utf8; } if ( !OLD_PERL ) { *JSON::PP::JSON_PP_encode_ascii = \&_encode_ascii; *JSON::PP::JSON_PP_encode_latin1 = \&_encode_latin1; *JSON::PP::JSON_PP_decode_surrogates = \&_decode_surrogates; *JSON::PP::JSON_PP_decode_unicode = \&_decode_unicode; if ($] < 5.008003) { # join() in 5.8.0 - 5.8.2 is broken. package JSON::PP; require subs; subs->import('join'); eval q| sub join { return '' if (@_ < 2); my $j = shift; my $str = shift; for (@_) { $str .= $j . $_; } return $str; } |; } } sub JSON::PP::incr_parse { local $Carp::CarpLevel = 1; ( $_[0]->{_incr_parser} ||= JSON::PP::IncrParser->new )->incr_parse( @_ ); } sub JSON::PP::incr_skip { ( $_[0]->{_incr_parser} ||= JSON::PP::IncrParser->new )->incr_skip; } sub JSON::PP::incr_reset { ( $_[0]->{_incr_parser} ||= JSON::PP::IncrParser->new )->incr_reset; } eval q{ sub JSON::PP::incr_text : lvalue { $_[0]->{_incr_parser} ||= JSON::PP::IncrParser->new; if ( $_[0]->{_incr_parser}->{incr_pos} ) { Carp::croak("incr_text cannot be called when the incremental parser already started parsing"); } $_[0]->{_incr_parser}->{incr_text}; } } if ( $] >= 5.006 ); } # Setup for various Perl versions (the code from JSON::PP58) ############################### # Utilities # BEGIN { eval 'require Scalar::Util'; unless($@){ *JSON::PP::blessed = \&Scalar::Util::blessed; *JSON::PP::reftype = \&Scalar::Util::reftype; *JSON::PP::refaddr = \&Scalar::Util::refaddr; } else{ # This code is from Scalar::Util. # warn $@; eval 'sub UNIVERSAL::a_sub_not_likely_to_be_here { ref($_[0]) }'; *JSON::PP::blessed = sub { local($@, $SIG{__DIE__}, $SIG{__WARN__}); ref($_[0]) ? eval { $_[0]->a_sub_not_likely_to_be_here } : undef; }; require B; my %tmap = qw( B::NULL SCALAR B::HV HASH B::AV ARRAY B::CV CODE B::IO IO B::GV GLOB B::REGEXP REGEXP ); *JSON::PP::reftype = sub { my $r = shift; return undef unless length(ref($r)); my $t = ref(B::svref_2object($r)); return exists $tmap{$t} ? $tmap{$t} : length(ref($$r)) ? 'REF' : 'SCALAR'; }; *JSON::PP::refaddr = sub { return undef unless length(ref($_[0])); my $addr; if(defined(my $pkg = blessed($_[0]))) { $addr .= bless $_[0], 'Scalar::Util::Fake'; bless $_[0], $pkg; } else { $addr .= $_[0] } $addr =~ /0x(\w+)/; local $^W; #no warnings 'portable'; hex($1); } } } # shamelessly copied and modified from JSON::XS code. $JSON::PP::true = do { bless \(my $dummy = 1), "JSON::PP::Boolean" }; $JSON::PP::false = do { bless \(my $dummy = 0), "JSON::PP::Boolean" }; sub is_bool { blessed $_[0] and $_[0]->isa("JSON::PP::Boolean"); } sub true { $JSON::PP::true } sub false { $JSON::PP::false } sub null { undef; } ############################### package JSON::PP::IncrParser; use strict; use constant INCR_M_WS => 0; # initial whitespace skipping use constant INCR_M_STR => 1; # inside string use constant INCR_M_BS => 2; # inside backslash use constant INCR_M_JSON => 3; # outside anything, count nesting use constant INCR_M_C0 => 4; use constant INCR_M_C1 => 5; $JSON::PP::IncrParser::VERSION = '1.01'; sub new { my ( $class ) = @_; bless { incr_nest => 0, incr_text => undef, incr_pos => 0, incr_mode => 0, }, $class; } sub incr_parse { my ( $self, $coder, $text ) = @_; $self->{incr_text} = '' unless ( defined $self->{incr_text} ); if ( defined $text ) { if ( utf8::is_utf8( $text ) and !utf8::is_utf8( $self->{incr_text} ) ) { utf8::upgrade( $self->{incr_text} ) ; utf8::decode( $self->{incr_text} ) ; } $self->{incr_text} .= $text; } if ( defined wantarray ) { my $max_size = $coder->get_max_size; my $p = $self->{incr_pos}; my @ret; { do { unless ( $self->{incr_nest} <= 0 and $self->{incr_mode} == INCR_M_JSON ) { $self->_incr_parse( $coder ); if ( $max_size and $self->{incr_pos} > $max_size ) { Carp::croak("attempted decode of JSON text of $self->{incr_pos} bytes size, but max_size is set to $max_size"); } unless ( $self->{incr_nest} <= 0 and $self->{incr_mode} == INCR_M_JSON ) { # as an optimisation, do not accumulate white space in the incr buffer if ( $self->{incr_mode} == INCR_M_WS and $self->{incr_pos} ) { $self->{incr_pos} = 0; $self->{incr_text} = ''; } last; } } my ($obj, $offset) = $coder->PP_decode_json( $self->{incr_text}, 0x00000001 ); push @ret, $obj; use bytes; $self->{incr_text} = substr( $self->{incr_text}, $offset || 0 ); $self->{incr_pos} = 0; $self->{incr_nest} = 0; $self->{incr_mode} = 0; last unless wantarray; } while ( wantarray ); } if ( wantarray ) { return @ret; } else { # in scalar context return $ret[0] ? $ret[0] : undef; } } } sub _incr_parse { my ($self, $coder) = @_; my $text = $self->{incr_text}; my $len = length $text; my $p = $self->{incr_pos}; INCR_PARSE: while ( $len > $p ) { my $s = substr( $text, $p, 1 ); last INCR_PARSE unless defined $s; my $mode = $self->{incr_mode}; if ( $mode == INCR_M_WS ) { while ( $len > $p ) { $s = substr( $text, $p, 1 ); last INCR_PARSE unless defined $s; if ( ord($s) > 0x20 ) { if ( $s eq '#' ) { $self->{incr_mode} = INCR_M_C0; redo INCR_PARSE; } else { $self->{incr_mode} = INCR_M_JSON; redo INCR_PARSE; } } $p++; } } elsif ( $mode == INCR_M_BS ) { $p++; $self->{incr_mode} = INCR_M_STR; redo INCR_PARSE; } elsif ( $mode == INCR_M_C0 or $mode == INCR_M_C1 ) { while ( $len > $p ) { $s = substr( $text, $p, 1 ); last INCR_PARSE unless defined $s; if ( $s eq "\n" ) { $self->{incr_mode} = $self->{incr_mode} == INCR_M_C0 ? INCR_M_WS : INCR_M_JSON; last; } $p++; } next; } elsif ( $mode == INCR_M_STR ) { while ( $len > $p ) { $s = substr( $text, $p, 1 ); last INCR_PARSE unless defined $s; if ( $s eq '"' ) { $p++; $self->{incr_mode} = INCR_M_JSON; last INCR_PARSE unless $self->{incr_nest}; redo INCR_PARSE; } elsif ( $s eq '\\' ) { $p++; if ( !defined substr($text, $p, 1) ) { $self->{incr_mode} = INCR_M_BS; last INCR_PARSE; } } $p++; } } elsif ( $mode == INCR_M_JSON ) { while ( $len > $p ) { $s = substr( $text, $p++, 1 ); if ( $s eq "\x00" ) { $p--; last INCR_PARSE; } elsif ( $s eq "\x09" or $s eq "\x0a" or $s eq "\x0d" or $s eq "\x20" ) { if ( !$self->{incr_nest} ) { $p--; # do not eat the whitespace, let the next round do it last INCR_PARSE; } next; } elsif ( $s eq '"' ) { $self->{incr_mode} = INCR_M_STR; redo INCR_PARSE; } elsif ( $s eq '[' or $s eq '{' ) { if ( ++$self->{incr_nest} > $coder->get_max_depth ) { Carp::croak('json text or perl structure exceeds maximum nesting level (max_depth set too low?)'); } next; } elsif ( $s eq ']' or $s eq '}' ) { if ( --$self->{incr_nest} <= 0 ) { last INCR_PARSE; } } elsif ( $s eq '#' ) { $self->{incr_mode} = INCR_M_C1; redo INCR_PARSE; } } } } $self->{incr_pos} = $p; $self->{incr_parsing} = $p ? 1 : 0; # for backward compatibility } sub incr_text { if ( $_[0]->{incr_pos} ) { Carp::croak("incr_text cannot be called when the incremental parser already started parsing"); } $_[0]->{incr_text}; } sub incr_skip { my $self = shift; $self->{incr_text} = substr( $self->{incr_text}, $self->{incr_pos} ); $self->{incr_pos} = 0; $self->{incr_mode} = 0; $self->{incr_nest} = 0; } sub incr_reset { my $self = shift; $self->{incr_text} = undef; $self->{incr_pos} = 0; $self->{incr_mode} = 0; $self->{incr_nest} = 0; } ############################### 1; __END__ =pod =head1 NAME JSON::PP - JSON::XS compatible pure-Perl module. =head1 SYNOPSIS use JSON::PP; # exported functions, they croak on error # and expect/generate UTF-8 $utf8_encoded_json_text = encode_json $perl_hash_or_arrayref; $perl_hash_or_arrayref = decode_json $utf8_encoded_json_text; # OO-interface $json = JSON::PP->new->ascii->pretty->allow_nonref; $pretty_printed_json_text = $json->encode( $perl_scalar ); $perl_scalar = $json->decode( $json_text ); # Note that JSON version 2.0 and above will automatically use # JSON::XS or JSON::PP, so you should be able to just: use JSON; =head1 VERSION 2.97001 =head1 DESCRIPTION JSON::PP is a pure perl JSON decoder/encoder (as of RFC4627, which we know is obsolete but we still stick to; see below for an option to support part of RFC7159), and (almost) compatible to much faster L written by Marc Lehmann in C. JSON::PP works as a fallback module when you use L module without having installed JSON::XS. Because of this fallback feature of JSON.pm, JSON::PP tries not to be more JavaScript-friendly than JSON::XS (i.e. not to escape extra characters such as U+2028 and U+2029 nor support RFC7159/ECMA-404), in order for you not to lose such JavaScript-friendliness silently when you use JSON.pm and install JSON::XS for speed or by accident. If you need JavaScript-friendly RFC7159-compliant pure perl module, try L, which is derived from L web framework and is also smaller and faster than JSON::PP. JSON::PP has been in the Perl core since Perl 5.14, mainly for CPAN toolchain modules to parse META.json. =head1 FUNCTIONAL INTERFACE This section is taken from JSON::XS almost verbatim. C and C are exported by default. =head2 encode_json $json_text = encode_json $perl_scalar Converts the given Perl data structure to a UTF-8 encoded, binary string (that is, the string contains octets only). Croaks on error. This function call is functionally identical to: $json_text = JSON::PP->new->utf8->encode($perl_scalar) Except being faster. =head2 decode_json $perl_scalar = decode_json $json_text The opposite of C: expects an UTF-8 (binary) string and tries to parse that as an UTF-8 encoded JSON text, returning the resulting reference. Croaks on error. This function call is functionally identical to: $perl_scalar = JSON::PP->new->utf8->decode($json_text) Except being faster. =head2 JSON::PP::is_bool $is_boolean = JSON::PP::is_bool($scalar) Returns true if the passed scalar represents either JSON::PP::true or JSON::PP::false, two constants that act like C<1> and C<0> respectively and are also used to represent JSON C and C in Perl strings. See L, below, for more information on how JSON values are mapped to Perl. =head1 OBJECT-ORIENTED INTERFACE This section is also taken from JSON::XS. The object oriented interface lets you configure your own encoding or decoding style, within the limits of supported formats. =head2 new $json = JSON::PP->new Creates a new JSON::PP object that can be used to de/encode JSON strings. All boolean flags described below are by default I. The mutators for flags all return the JSON::PP object again and thus calls can be chained: my $json = JSON::PP->new->utf8->space_after->encode({a => [1,2]}) => {"a": [1, 2]} =head2 ascii $json = $json->ascii([$enable]) $enabled = $json->get_ascii If C<$enable> is true (or missing), then the C method will not generate characters outside the code range C<0..127> (which is ASCII). Any Unicode characters outside that range will be escaped using either a single \uXXXX (BMP characters) or a double \uHHHH\uLLLLL escape sequence, as per RFC4627. The resulting encoded JSON text can be treated as a native Unicode string, an ascii-encoded, latin1-encoded or UTF-8 encoded string, or any other superset of ASCII. If C<$enable> is false, then the C method will not escape Unicode characters unless required by the JSON syntax or other flags. This results in a faster and more compact format. See also the section I later in this document. The main use for this flag is to produce JSON texts that can be transmitted over a 7-bit channel, as the encoded JSON texts will not contain any 8 bit characters. JSON::PP->new->ascii(1)->encode([chr 0x10401]) => ["\ud801\udc01"] =head2 latin1 $json = $json->latin1([$enable]) $enabled = $json->get_latin1 If C<$enable> is true (or missing), then the C method will encode the resulting JSON text as latin1 (or iso-8859-1), escaping any characters outside the code range C<0..255>. The resulting string can be treated as a latin1-encoded JSON text or a native Unicode string. The C method will not be affected in any way by this flag, as C by default expects Unicode, which is a strict superset of latin1. If C<$enable> is false, then the C method will not escape Unicode characters unless required by the JSON syntax or other flags. See also the section I later in this document. The main use for this flag is efficiently encoding binary data as JSON text, as most octets will not be escaped, resulting in a smaller encoded size. The disadvantage is that the resulting JSON text is encoded in latin1 (and must correctly be treated as such when storing and transferring), a rare encoding for JSON. It is therefore most useful when you want to store data structures known to contain binary data efficiently in files or databases, not when talking to other JSON encoders/decoders. JSON::PP->new->latin1->encode (["\x{89}\x{abc}"] => ["\x{89}\\u0abc"] # (perl syntax, U+abc escaped, U+89 not) =head2 utf8 $json = $json->utf8([$enable]) $enabled = $json->get_utf8 If C<$enable> is true (or missing), then the C method will encode the JSON result into UTF-8, as required by many protocols, while the C method expects to be handled an UTF-8-encoded string. Please note that UTF-8-encoded strings do not contain any characters outside the range C<0..255>, they are thus useful for bytewise/binary I/O. In future versions, enabling this option might enable autodetection of the UTF-16 and UTF-32 encoding families, as described in RFC4627. If C<$enable> is false, then the C method will return the JSON string as a (non-encoded) Unicode string, while C expects thus a Unicode string. Any decoding or encoding (e.g. to UTF-8 or UTF-16) needs to be done yourself, e.g. using the Encode module. See also the section I later in this document. Example, output UTF-16BE-encoded JSON: use Encode; $jsontext = encode "UTF-16BE", JSON::PP->new->encode ($object); Example, decode UTF-32LE-encoded JSON: use Encode; $object = JSON::PP->new->decode (decode "UTF-32LE", $jsontext); =head2 pretty $json = $json->pretty([$enable]) This enables (or disables) all of the C, C and C (and in the future possibly more) flags in one call to generate the most readable (or most compact) form possible. =head2 indent $json = $json->indent([$enable]) $enabled = $json->get_indent If C<$enable> is true (or missing), then the C method will use a multiline format as output, putting every array member or object/hash key-value pair into its own line, indenting them properly. If C<$enable> is false, no newlines or indenting will be produced, and the resulting JSON text is guaranteed not to contain any C. This setting has no effect when decoding JSON texts. The default indent space length is three. You can use C to change the length. =head2 space_before $json = $json->space_before([$enable]) $enabled = $json->get_space_before If C<$enable> is true (or missing), then the C method will add an extra optional space before the C<:> separating keys from values in JSON objects. If C<$enable> is false, then the C method will not add any extra space at those places. This setting has no effect when decoding JSON texts. You will also most likely combine this setting with C. Example, space_before enabled, space_after and indent disabled: {"key" :"value"} =head2 space_after $json = $json->space_after([$enable]) $enabled = $json->get_space_after If C<$enable> is true (or missing), then the C method will add an extra optional space after the C<:> separating keys from values in JSON objects and extra whitespace after the C<,> separating key-value pairs and array members. If C<$enable> is false, then the C method will not add any extra space at those places. This setting has no effect when decoding JSON texts. Example, space_before and indent disabled, space_after enabled: {"key": "value"} =head2 relaxed $json = $json->relaxed([$enable]) $enabled = $json->get_relaxed If C<$enable> is true (or missing), then C will accept some extensions to normal JSON syntax (see below). C will not be affected in anyway. I. I suggest only to use this option to parse application-specific files written by humans (configuration files, resource files etc.) If C<$enable> is false (the default), then C will only accept valid JSON texts. Currently accepted extensions are: =over 4 =item * list items can have an end-comma JSON I array elements and key-value pairs with commas. This can be annoying if you write JSON texts manually and want to be able to quickly append elements, so this extension accepts comma at the end of such items not just between them: [ 1, 2, <- this comma not normally allowed ] { "k1": "v1", "k2": "v2", <- this comma not normally allowed } =item * shell-style '#'-comments Whenever JSON allows whitespace, shell-style comments are additionally allowed. They are terminated by the first carriage-return or line-feed character, after which more white-space and comments are allowed. [ 1, # this comment not allowed in JSON # neither this one... ] =item * C-style multiple-line '/* */'-comments (JSON::PP only) Whenever JSON allows whitespace, C-style multiple-line comments are additionally allowed. Everything between C and C<*/> is a comment, after which more white-space and comments are allowed. [ 1, /* this comment not allowed in JSON */ /* neither this one... */ ] =item * C++-style one-line '//'-comments (JSON::PP only) Whenever JSON allows whitespace, C++-style one-line comments are additionally allowed. They are terminated by the first carriage-return or line-feed character, after which more white-space and comments are allowed. [ 1, // this comment not allowed in JSON // neither this one... ] =back =head2 canonical $json = $json->canonical([$enable]) $enabled = $json->get_canonical If C<$enable> is true (or missing), then the C method will output JSON objects by sorting their keys. This is adding a comparatively high overhead. If C<$enable> is false, then the C method will output key-value pairs in the order Perl stores them (which will likely change between runs of the same script, and can change even within the same run from 5.18 onwards). This option is useful if you want the same data structure to be encoded as the same JSON text (given the same overall settings). If it is disabled, the same hash might be encoded differently even if contains the same data, as key-value pairs have no inherent ordering in Perl. This setting has no effect when decoding JSON texts. This setting has currently no effect on tied hashes. =head2 allow_nonref $json = $json->allow_nonref([$enable]) $enabled = $json->get_allow_nonref If C<$enable> is true (or missing), then the C method can convert a non-reference into its corresponding string, number or null JSON value, which is an extension to RFC4627. Likewise, C will accept those JSON values instead of croaking. If C<$enable> is false, then the C method will croak if it isn't passed an arrayref or hashref, as JSON texts must either be an object or array. Likewise, C will croak if given something that is not a JSON object or array. Example, encode a Perl scalar as JSON value with enabled C, resulting in an invalid JSON text: JSON::PP->new->allow_nonref->encode ("Hello, World!") => "Hello, World!" =head2 allow_unknown $json = $json->allow_unknown ([$enable]) $enabled = $json->get_allow_unknown If C<$enable> is true (or missing), then C will I throw an exception when it encounters values it cannot represent in JSON (for example, filehandles) but instead will encode a JSON C value. Note that blessed objects are not included here and are handled separately by c. If C<$enable> is false (the default), then C will throw an exception when it encounters anything it cannot encode as JSON. This option does not affect C in any way, and it is recommended to leave it off unless you know your communications partner. =head2 allow_blessed $json = $json->allow_blessed([$enable]) $enabled = $json->get_allow_blessed See L for details. If C<$enable> is true (or missing), then the C method will not barf when it encounters a blessed reference that it cannot convert otherwise. Instead, a JSON C value is encoded instead of the object. If C<$enable> is false (the default), then C will throw an exception when it encounters a blessed object that it cannot convert otherwise. This setting has no effect on C. =head2 convert_blessed $json = $json->convert_blessed([$enable]) $enabled = $json->get_convert_blessed See L for details. If C<$enable> is true (or missing), then C, upon encountering a blessed object, will check for the availability of the C method on the object's class. If found, it will be called in scalar context and the resulting scalar will be encoded instead of the object. The C method may safely call die if it wants. If C returns other blessed objects, those will be handled in the same way. C must take care of not causing an endless recursion cycle (== crash) in this case. The name of C was chosen because other methods called by the Perl core (== not by the user of the object) are usually in upper case letters and to avoid collisions with any C function or method. If C<$enable> is false (the default), then C will not consider this type of conversion. This setting has no effect on C. =head2 filter_json_object $json = $json->filter_json_object([$coderef]) When C<$coderef> is specified, it will be called from C each time it decodes a JSON object. The only argument is a reference to the newly-created hash. If the code references returns a single scalar (which need not be a reference), this value (i.e. a copy of that scalar to avoid aliasing) is inserted into the deserialised data structure. If it returns an empty list (NOTE: I C, which is a valid scalar), the original deserialised hash will be inserted. This setting can slow down decoding considerably. When C<$coderef> is omitted or undefined, any existing callback will be removed and C will not change the deserialised hash in any way. Example, convert all JSON objects into the integer 5: my $js = JSON::PP->new->filter_json_object (sub { 5 }); # returns [5] $js->decode ('[{}]'); # the given subroutine takes a hash reference. # throw an exception because allow_nonref is not enabled # so a lone 5 is not allowed. $js->decode ('{"a":1, "b":2}'); =head2 filter_json_single_key_object $json = $json->filter_json_single_key_object($key [=> $coderef]) Works remotely similar to C, but is only called for JSON objects having a single key named C<$key>. This C<$coderef> is called before the one specified via C, if any. It gets passed the single value in the JSON object. If it returns a single value, it will be inserted into the data structure. If it returns nothing (not even C but the empty list), the callback from C will be called next, as if no single-key callback were specified. If C<$coderef> is omitted or undefined, the corresponding callback will be disabled. There can only ever be one callback for a given key. As this callback gets called less often then the C one, decoding speed will not usually suffer as much. Therefore, single-key objects make excellent targets to serialise Perl objects into, especially as single-key JSON objects are as close to the type-tagged value concept as JSON gets (it's basically an ID/VALUE tuple). Of course, JSON does not support this in any way, so you need to make sure your data never looks like a serialised Perl hash. Typical names for the single object key are C<__class_whatever__>, or C<$__dollars_are_rarely_used__$> or C<}ugly_brace_placement>, or even things like C<__class_md5sum(classname)__>, to reduce the risk of clashing with real hashes. Example, decode JSON objects of the form C<< { "__widget__" => } >> into the corresponding C<< $WIDGET{} >> object: # return whatever is in $WIDGET{5}: JSON::PP ->new ->filter_json_single_key_object (__widget__ => sub { $WIDGET{ $_[0] } }) ->decode ('{"__widget__": 5') # this can be used with a TO_JSON method in some "widget" class # for serialisation to json: sub WidgetBase::TO_JSON { my ($self) = @_; unless ($self->{id}) { $self->{id} = ..get..some..id..; $WIDGET{$self->{id}} = $self; } { __widget__ => $self->{id} } } =head2 shrink $json = $json->shrink([$enable]) $enabled = $json->get_shrink If C<$enable> is true (or missing), the string returned by C will be shrunk (i.e. downgraded if possible). The actual definition of what shrink does might change in future versions, but it will always try to save space at the expense of time. If C<$enable> is false, then JSON::PP does nothing. =head2 max_depth $json = $json->max_depth([$maximum_nesting_depth]) $max_depth = $json->get_max_depth Sets the maximum nesting level (default C<512>) accepted while encoding or decoding. If a higher nesting level is detected in JSON text or a Perl data structure, then the encoder and decoder will stop and croak at that point. Nesting level is defined by number of hash- or arrayrefs that the encoder needs to traverse to reach a given point or the number of C<{> or C<[> characters without their matching closing parenthesis crossed to reach a given character in a string. Setting the maximum depth to one disallows any nesting, so that ensures that the object is only a single hash/object or array. If no argument is given, the highest possible setting will be used, which is rarely useful. See L for more info on why this is useful. =head2 max_size $json = $json->max_size([$maximum_string_size]) $max_size = $json->get_max_size Set the maximum length a JSON text may have (in bytes) where decoding is being attempted. The default is C<0>, meaning no limit. When C is called on a string that is longer then this many bytes, it will not attempt to decode the string but throw an exception. This setting has no effect on C (yet). If no argument is given, the limit check will be deactivated (same as when C<0> is specified). See L for more info on why this is useful. =head2 encode $json_text = $json->encode($perl_scalar) Converts the given Perl value or data structure to its JSON representation. Croaks on error. =head2 decode $perl_scalar = $json->decode($json_text) The opposite of C: expects a JSON text and tries to parse it, returning the resulting simple scalar or reference. Croaks on error. =head2 decode_prefix ($perl_scalar, $characters) = $json->decode_prefix($json_text) This works like the C method, but instead of raising an exception when there is trailing garbage after the first JSON object, it will silently stop parsing there and return the number of characters consumed so far. This is useful if your JSON texts are not delimited by an outer protocol and you need to know where the JSON text ends. JSON::PP->new->decode_prefix ("[1] the tail") => ([1], 3) =head1 FLAGS FOR JSON::PP ONLY The following flags and properties are for JSON::PP only. If you use any of these, you can't make your application run faster by replacing JSON::PP with JSON::XS. If you need these and also speed boost, try L, a fork of JSON::XS by Reini Urban, which supports some of these. =head2 allow_singlequote $json = $json->allow_singlequote([$enable]) $enabled = $json->get_allow_singlequote If C<$enable> is true (or missing), then C will accept invalid JSON texts that contain strings that begin and end with single quotation marks. C will not be affected in anyway. I. I suggest only to use this option to parse application-specific files written by humans (configuration files, resource files etc.) If C<$enable> is false (the default), then C will only accept valid JSON texts. $json->allow_singlequote->decode(qq|{"foo":'bar'}|); $json->allow_singlequote->decode(qq|{'foo':"bar"}|); $json->allow_singlequote->decode(qq|{'foo':'bar'}|); =head2 allow_barekey $json = $json->allow_barekey([$enable]) $enabled = $json->get_allow_barekey If C<$enable> is true (or missing), then C will accept invalid JSON texts that contain JSON objects whose names don't begin and end with quotation marks. C will not be affected in anyway. I. I suggest only to use this option to parse application-specific files written by humans (configuration files, resource files etc.) If C<$enable> is false (the default), then C will only accept valid JSON texts. $json->allow_barekey->decode(qq|{foo:"bar"}|); =head2 allow_bignum $json = $json->allow_bignum([$enable]) $enabled = $json->get_allow_bignum If C<$enable> is true (or missing), then C will convert big integers Perl cannot handle as integer into L objects and convert floating numbers into L objects. C will convert C and C objects into JSON numbers. $json->allow_nonref->allow_bignum; $bigfloat = $json->decode('2.000000000000000000000000001'); print $json->encode($bigfloat); # => 2.000000000000000000000000001 See also L. =head2 loose $json = $json->loose([$enable]) $enabled = $json->get_loose If C<$enable> is true (or missing), then C will accept invalid JSON texts that contain unescaped [\x00-\x1f\x22\x5c] characters. C will not be affected in anyway. I. I suggest only to use this option to parse application-specific files written by humans (configuration files, resource files etc.) If C<$enable> is false (the default), then C will only accept valid JSON texts. $json->loose->decode(qq|["abc def"]|); =head2 escape_slash $json = $json->escape_slash([$enable]) $enabled = $json->get_escape_slash If C<$enable> is true (or missing), then C will explicitly escape I (solidus; C) characters to reduce the risk of XSS (cross site scripting) that may be caused by C<< >> in a JSON text, with the cost of bloating the size of JSON texts. This option may be useful when you embed JSON in HTML, but embedding arbitrary JSON in HTML (by some HTML template toolkit or by string interpolation) is risky in general. You must escape necessary characters in correct order, depending on the context. C will not be affected in anyway. =head2 indent_length $json = $json->indent_length($number_of_spaces) $length = $json->get_indent_length This option is only useful when you also enable C or C. JSON::XS indents with three spaces when you C (if requested by C or C), and the number cannot be changed. JSON::PP allows you to change/get the number of indent spaces with these mutator/accessor. The default number of spaces is three (the same as JSON::XS), and the acceptable range is from C<0> (no indentation; it'd be better to disable indentation by C) to C<15>. =head2 sort_by $json = $json->sort_by($code_ref) $json = $json->sort_by($subroutine_name) If you just want to sort keys (names) in JSON objects when you C, enable C option (see above) that allows you to sort object keys alphabetically. If you do need to sort non-alphabetically for whatever reasons, you can give a code reference (or a subroutine name) to C, then the argument will be passed to Perl's C built-in function. As the sorting is done in the JSON::PP scope, you usually need to prepend C to the subroutine name, and the special variables C<$a> and C<$b> used in the subrontine used by C function. Example: my %ORDER = (id => 1, class => 2, name => 3); $json->sort_by(sub { ($ORDER{$JSON::PP::a} // 999) <=> ($ORDER{$JSON::PP::b} // 999) or $JSON::PP::a cmp $JSON::PP::b }); print $json->encode([ {name => 'CPAN', id => 1, href => 'http://cpan.org'} ]); # [{"id":1,"name":"CPAN","href":"http://cpan.org"}] Note that C affects all the plain hashes in the data structure. If you need finer control, C necessary hashes with a module that implements ordered hash (such as L and L). C and C don't affect the key order in Cd hashes. use Hash::Ordered; tie my %hash, 'Hash::Ordered', (name => 'CPAN', id => 1, href => 'http://cpan.org'); print $json->encode([\%hash]); # [{"name":"CPAN","id":1,"href":"http://cpan.org"}] # order is kept =head1 INCREMENTAL PARSING This section is also taken from JSON::XS. In some cases, there is the need for incremental parsing of JSON texts. While this module always has to keep both JSON text and resulting Perl data structure in memory at one time, it does allow you to parse a JSON stream incrementally. It does so by accumulating text until it has a full JSON object, which it then can decode. This process is similar to using C to see if a full JSON object is available, but is much more efficient (and can be implemented with a minimum of method calls). JSON::PP will only attempt to parse the JSON text once it is sure it has enough text to get a decisive result, using a very simple but truly incremental parser. This means that it sometimes won't stop as early as the full parser, for example, it doesn't detect mismatched parentheses. The only thing it guarantees is that it starts decoding as soon as a syntactically valid JSON text has been seen. This means you need to set resource limits (e.g. C) to ensure the parser will stop parsing in the presence if syntax errors. The following methods implement this incremental parser. =head2 incr_parse $json->incr_parse( [$string] ) # void context $obj_or_undef = $json->incr_parse( [$string] ) # scalar context @obj_or_empty = $json->incr_parse( [$string] ) # list context This is the central parsing function. It can both append new text and extract objects from the stream accumulated so far (both of these functions are optional). If C<$string> is given, then this string is appended to the already existing JSON fragment stored in the C<$json> object. After that, if the function is called in void context, it will simply return without doing anything further. This can be used to add more text in as many chunks as you want. If the method is called in scalar context, then it will try to extract exactly I JSON object. If that is successful, it will return this object, otherwise it will return C. If there is a parse error, this method will croak just as C would do (one can then use C to skip the erroneous part). This is the most common way of using the method. And finally, in list context, it will try to extract as many objects from the stream as it can find and return them, or the empty list otherwise. For this to work, there must be no separators (other than whitespace) between the JSON objects or arrays, instead they must be concatenated back-to-back. If an error occurs, an exception will be raised as in the scalar context case. Note that in this case, any previously-parsed JSON texts will be lost. Example: Parse some JSON arrays/objects in a given string and return them. my @objs = JSON::PP->new->incr_parse ("[5][7][1,2]"); =head2 incr_text $lvalue_string = $json->incr_text This method returns the currently stored JSON fragment as an lvalue, that is, you can manipulate it. This I works when a preceding call to C in I successfully returned an object. Under all other circumstances you must not call this function (I mean it. although in simple tests it might actually work, it I fail under real world conditions). As a special exception, you can also call this method before having parsed anything. That means you can only use this function to look at or manipulate text before or after complete JSON objects, not while the parser is in the middle of parsing a JSON object. This function is useful in two cases: a) finding the trailing text after a JSON object or b) parsing multiple JSON objects separated by non-JSON text (such as commas). =head2 incr_skip $json->incr_skip This will reset the state of the incremental parser and will remove the parsed text from the input buffer so far. This is useful after C died, in which case the input buffer and incremental parser state is left unchanged, to skip the text parsed so far and to reset the parse state. The difference to C is that only text until the parse error occurred is removed. =head2 incr_reset $json->incr_reset This completely resets the incremental parser, that is, after this call, it will be as if the parser had never parsed anything. This is useful if you want to repeatedly parse JSON objects and want to ignore any trailing data, which means you have to reset the parser after each successful decode. =head1 MAPPING Most of this section is also taken from JSON::XS. This section describes how JSON::PP maps Perl values to JSON values and vice versa. These mappings are designed to "do the right thing" in most circumstances automatically, preserving round-tripping characteristics (what you put in comes out as something equivalent). For the more enlightened: note that in the following descriptions, lowercase I refers to the Perl interpreter, while uppercase I refers to the abstract Perl language itself. =head2 JSON -> PERL =over 4 =item object A JSON object becomes a reference to a hash in Perl. No ordering of object keys is preserved (JSON does not preserve object key ordering itself). =item array A JSON array becomes a reference to an array in Perl. =item string A JSON string becomes a string scalar in Perl - Unicode codepoints in JSON are represented by the same codepoints in the Perl string, so no manual decoding is necessary. =item number A JSON number becomes either an integer, numeric (floating point) or string scalar in perl, depending on its range and any fractional parts. On the Perl level, there is no difference between those as Perl handles all the conversion details, but an integer may take slightly less memory and might represent more values exactly than floating point numbers. If the number consists of digits only, JSON::PP will try to represent it as an integer value. If that fails, it will try to represent it as a numeric (floating point) value if that is possible without loss of precision. Otherwise it will preserve the number as a string value (in which case you lose roundtripping ability, as the JSON number will be re-encoded to a JSON string). Numbers containing a fractional or exponential part will always be represented as numeric (floating point) values, possibly at a loss of precision (in which case you might lose perfect roundtripping ability, but the JSON number will still be re-encoded as a JSON number). Note that precision is not accuracy - binary floating point values cannot represent most decimal fractions exactly, and when converting from and to floating point, JSON::PP only guarantees precision up to but not including the least significant bit. When C is enabled, big integer values and any numeric values will be converted into L and L objects respectively, without becoming string scalars or losing precision. =item true, false These JSON atoms become C and C, respectively. They are overloaded to act almost exactly like the numbers C<1> and C<0>. You can check whether a scalar is a JSON boolean by using the C function. =item null A JSON null atom becomes C in Perl. =item shell-style comments (C<< # I >>) As a nonstandard extension to the JSON syntax that is enabled by the C setting, shell-style comments are allowed. They can start anywhere outside strings and go till the end of the line. =back =head2 PERL -> JSON The mapping from Perl to JSON is slightly more difficult, as Perl is a truly typeless language, so we can only guess which JSON type is meant by a Perl value. =over 4 =item hash references Perl hash references become JSON objects. As there is no inherent ordering in hash keys (or JSON objects), they will usually be encoded in a pseudo-random order. JSON::PP can optionally sort the hash keys (determined by the I flag and/or I property), so the same data structure will serialise to the same JSON text (given same settings and version of JSON::PP), but this incurs a runtime overhead and is only rarely useful, e.g. when you want to compare some JSON text against another for equality. =item array references Perl array references become JSON arrays. =item other references Other unblessed references are generally not allowed and will cause an exception to be thrown, except for references to the integers C<0> and C<1>, which get turned into C and C atoms in JSON. You can also use C and C to improve readability. to_json [\0, JSON::PP::true] # yields [false,true] =item JSON::PP::true, JSON::PP::false These special values become JSON true and JSON false values, respectively. You can also use C<\1> and C<\0> directly if you want. =item JSON::PP::null This special value becomes JSON null. =item blessed objects Blessed objects are not directly representable in JSON, but C allows various ways of handling objects. See L, below, for details. =item simple scalars Simple Perl scalars (any scalar that is not a reference) are the most difficult objects to encode: JSON::PP will encode undefined scalars as JSON C values, scalars that have last been used in a string context before encoding as JSON strings, and anything else as number value: # dump as number encode_json [2] # yields [2] encode_json [-3.0e17] # yields [-3e+17] my $value = 5; encode_json [$value] # yields [5] # used as string, so dump as string print $value; encode_json [$value] # yields ["5"] # undef becomes null encode_json [undef] # yields [null] You can force the type to be a string by stringifying it: my $x = 3.1; # some variable containing a number "$x"; # stringified $x .= ""; # another, more awkward way to stringify print $x; # perl does it for you, too, quite often # (but for older perls) You can force the type to be a number by numifying it: my $x = "3"; # some variable containing a string $x += 0; # numify it, ensuring it will be dumped as a number $x *= 1; # same thing, the choice is yours. You cannot currently force the type in other, less obscure, ways. Note that numerical precision has the same meaning as under Perl (so binary to decimal conversion follows the same rules as in Perl, which can differ to other languages). Also, your perl interpreter might expose extensions to the floating point numbers of your platform, such as infinities or NaN's - these cannot be represented in JSON, and it is an error to pass those in. JSON::PP (and JSON::XS) trusts what you pass to C method (or C function) is a clean, validated data structure with values that can be represented as valid JSON values only, because it's not from an external data source (as opposed to JSON texts you pass to C or C, which JSON::PP considers tainted and doesn't trust). As JSON::PP doesn't know exactly what you and consumers of your JSON texts want the unexpected values to be (you may want to convert them into null, or to stringify them with or without normalisation (string representation of infinities/NaN may vary depending on platforms), or to croak without conversion), you're advised to do what you and your consumers need before you encode, and also not to numify values that may start with values that look like a number (including infinities/NaN), without validating. =back =head2 OBJECT SERIALISATION As for Perl objects, JSON::PP only supports a pure JSON representation (without the ability to deserialise the object automatically again). =head3 SERIALISATION What happens when C encounters a Perl object depends on the C, C and C settings, which are used in this order: =over 4 =item 1. C is enabled and the object has a C method. In this case, the C method of the object is invoked in scalar context. It must return a single scalar that can be directly encoded into JSON. This scalar replaces the object in the JSON text. For example, the following C method will convert all L objects to JSON strings when serialised. The fact that these values originally were L objects is lost. sub URI::TO_JSON { my ($uri) = @_; $uri->as_string } =item 2. C is enabled and the object is a C or C. The object will be serialised as a JSON number value. =item 3. C is enabled. The object will be serialised as a JSON null value. =item 4. none of the above If none of the settings are enabled or the respective methods are missing, C throws an exception. =back =head1 ENCODING/CODESET FLAG NOTES This section is taken from JSON::XS. The interested reader might have seen a number of flags that signify encodings or codesets - C, C and C. There seems to be some confusion on what these do, so here is a short comparison: C controls whether the JSON text created by C (and expected by C) is UTF-8 encoded or not, while C and C only control whether C escapes character values outside their respective codeset range. Neither of these flags conflict with each other, although some combinations make less sense than others. Care has been taken to make all flags symmetrical with respect to C and C, that is, texts encoded with any combination of these flag values will be correctly decoded when the same flags are used - in general, if you use different flag settings while encoding vs. when decoding you likely have a bug somewhere. Below comes a verbose discussion of these flags. Note that a "codeset" is simply an abstract set of character-codepoint pairs, while an encoding takes those codepoint numbers and I them, in our case into octets. Unicode is (among other things) a codeset, UTF-8 is an encoding, and ISO-8859-1 (= latin 1) and ASCII are both codesets I encodings at the same time, which can be confusing. =over 4 =item C flag disabled When C is disabled (the default), then C/C generate and expect Unicode strings, that is, characters with high ordinal Unicode values (> 255) will be encoded as such characters, and likewise such characters are decoded as-is, no changes to them will be done, except "(re-)interpreting" them as Unicode codepoints or Unicode characters, respectively (to Perl, these are the same thing in strings unless you do funny/weird/dumb stuff). This is useful when you want to do the encoding yourself (e.g. when you want to have UTF-16 encoded JSON texts) or when some other layer does the encoding for you (for example, when printing to a terminal using a filehandle that transparently encodes to UTF-8 you certainly do NOT want to UTF-8 encode your data first and have Perl encode it another time). =item C flag enabled If the C-flag is enabled, C/C will encode all characters using the corresponding UTF-8 multi-byte sequence, and will expect your input strings to be encoded as UTF-8, that is, no "character" of the input string must have any value > 255, as UTF-8 does not allow that. The C flag therefore switches between two modes: disabled means you will get a Unicode string in Perl, enabled means you get an UTF-8 encoded octet/binary string in Perl. =item C or C flags enabled With C (or C) enabled, C will escape characters with ordinal values > 255 (> 127 with C) and encode the remaining characters as specified by the C flag. If C is disabled, then the result is also correctly encoded in those character sets (as both are proper subsets of Unicode, meaning that a Unicode string with all character values < 256 is the same thing as a ISO-8859-1 string, and a Unicode string with all character values < 128 is the same thing as an ASCII string in Perl). If C is enabled, you still get a correct UTF-8-encoded string, regardless of these flags, just some more characters will be escaped using C<\uXXXX> then before. Note that ISO-8859-1-I strings are not compatible with UTF-8 encoding, while ASCII-encoded strings are. That is because the ISO-8859-1 encoding is NOT a subset of UTF-8 (despite the ISO-8859-1 I being a subset of Unicode), while ASCII is. Surprisingly, C will ignore these flags and so treat all input values as governed by the C flag. If it is disabled, this allows you to decode ISO-8859-1- and ASCII-encoded strings, as both strict subsets of Unicode. If it is enabled, you can correctly decode UTF-8 encoded strings. So neither C nor C are incompatible with the C flag - they only govern when the JSON output engine escapes a character or not. The main use for C is to relatively efficiently store binary data as JSON, at the expense of breaking compatibility with most JSON decoders. The main use for C is to force the output to not contain characters with values > 127, which means you can interpret the resulting string as UTF-8, ISO-8859-1, ASCII, KOI8-R or most about any character set and 8-bit-encoding, and still get the same data structure back. This is useful when your channel for JSON transfer is not 8-bit clean or the encoding might be mangled in between (e.g. in mail), and works because ASCII is a proper subset of most 8-bit and multibyte encodings in use in the world. =back =head1 SEE ALSO The F command line utility for quick experiments. L, L, and L for faster alternatives. L and L for easy migration. L and L for older perl users. RFC4627 (L) =head1 AUTHOR Makamaka Hannyaharamitu, Emakamaka[at]cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright 2007-2016 by Makamaka Hannyaharamitu This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut XS/.packlist000064400000000410152346607570006723 0ustar00/usr/local/bin/json_xs /usr/local/lib64/perl5/JSON/XS.pm /usr/local/lib64/perl5/JSON/XS/Boolean.pm /usr/local/lib64/perl5/auto/JSON/XS/XS.so /usr/local/share/man/man1/json_xs.1 /usr/local/share/man/man3/JSON::XS.3pm /usr/local/share/man/man3/JSON::XS::Boolean.3pm XS/XS.so000055500001147320152346607570006023 0ustar00ELF>#@@8 @$# 00 0  HH H 888$$``` Std``` Ptd@@@ddQtdRtd00 0 GNUw$ +GvM6rT` TVBE|z6qXSvC oe{r6:* e/ p { ^CZj!Kgk'D5, -F"8PRd wH  Pk __gmon_start___ITM_deregisterTMCloneTable_ITM_registerTMCloneTable__cxa_finalizelibpthread.so.0PL_thr_keypthread_getspecificPerl_sv_growPerl_croak_nocontextPerl_sv_2pv_flags__stack_chk_failmemcmppowPerl_sv_cmp_flagsPerl_newSVpvn_flagsPerl_sv_derived_fromPerl_sv_2mortalPerl_gv_stashpvPerl_croak_xs_usagePerl_stack_growPerl_sv_2iv_flagsPerl_newSVsvPerl_sv_chopPerl_sv_newmortalPerl_sv_setiv_mgPerl_sv_2uv_flagsPerl_sv_setuv_mgPerl_newSVPerl_newRV_noincPerl_sv_blessPerl_get_svPerl_utf8_lengthmemcpyPerl_newSVpvnPerl_utf8n_to_uvuniPerl_sv_free2Perl_hv_commonPerl_hv_placeholders_getPerl_newSV_typePerl_newSVnvPerl_av_pushPerl_hv_common_key_lenPerl_av_lenPerl_gv_stashsvPerl_gv_fetchmethod_autoloadPerl_push_scopePerl_savetmpsPerl_av_fetchPerl_call_svPerl_pop_scopePerl_newSVivPerl_grok_numberPerl_free_tmpsPerl_newSVuvPerl_markstack_growPerl_hv_iterinitPerl_hv_iternext_flagsPerl_hv_iterkeysvPerl_sv_utf8_upgrade_flags_growPerl_sv_upgradePerl_sv_utf8_downgradePerl_save_vptrPerl_pv_uni_displaymemmovePerl_block_gimmePL_utf8skipPL_hexdigit__sprintf_chkPerl_mg_getgcvtstrlen__snprintf_chkPerl_newRVmemsetPerl_hv_itervalqsortPerl_safesysreallocboot_JSON__XSPerl_xs_handshakePerl_newXS_deffilePerl_apply_attrs_stringPerl_newXS_flagsPerl_newSVpvPerl_get_cvPerl_xs_boot_epiloglibperl.so.5.26libc.so.6_edata__bss_start_endGLIBC_2.2.5GLIBC_2.14GLIBC_2.4GLIBC_2.3.4U ui |Zii ui |ti 0 P$8 $@ @    D J N Q` h p x                      ( 0 8 @  H !P "X #` $h %p &x ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; <( =0 >8 ?@ @H AP BX C` Eh Fp Gx H I K L M N O P R SHH HtH5Z %[ hhhhhhhhqhah Qh Ah 1h !h hhhhhhhhhhqhahQhAh1h!hhhh h!h"h#h$h%h&h'qh(ah)Qh*Ah+1h,!h-h.h/h0h1h2h3h4h5h6h7qh8ah9Qh:Ah;1h<!h=h>h?h@hAhBhChDhEhFhGqhHahIQhJAhK1hL!% D%} D%u D%m D%e D%] D%U D%M D%E D%= D%5 D%- D%% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D%} D%u D%m D%e D%] D%U D%M D%E D%= D%5 D%- D%% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D% D%} D%u D%m D%e D%] D%U D%M D%E D%= D%5 D%- D%% DH=Y HR H9tH Ht H=) H5" H)HHH?HHtH HtfD= u+UH= Ht H= d ]wATUH-b S}}}HPxHJHHx}HcH H Hq H^ Q}L`EITH[]A\USHHrhHHHr]HHw6Eu HEH9Xs6H 8HHH[H]l@HHHEH[]H=1ff.@SHW dH%(HD$1ʃ wIH$t8 HuFHHPHGH$Hu1t 0tGHt$dH34%(u6H[@H 8 HHHH$뢐1gUSHHHHyH@HcOHcPHpH9HHHGH)DH[]AAVAAUIATIUSEH11%HHHPH90< v<; E$<5EuOfA*:Hx=fH*Y[AXMAMA,$]A\A]A^A)E$H؃fHH H*Xf(fEt{A),$LLE$묐G<-<+PЀ w0HO11@HTPp@ vAA)ЅDDE$EJf1LLsE$f.HLLLE$Ef.Ѓ0 BHЃ0 ~+GHOPЀ 3XGHOPЀ D1H(dH%(HD$1?-HT$ Ht$HD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L ;I2r;H((rH@ H)H~4Le;H rH(HD$HdH3%(u1HP[]A\A]A^D;qHHHoHDpH5NLqDAVIAUATUSHJ@ ;q;L q;HPxHJHHx*tqHcLH@HH)HHp;DmIHc>q;H@L4Ic,qH@H@ );qH@HH@@ ;pH@HH@HL(H@ H;I9t0p;H@L,pHLHn;p;H@HH@HhpLL H;Iip;H(_pH@ H)H~CLe;HDpH([]A\A]A^;)pH5Ho<; pHHHmHH=1pH5gL4o@ATUSHq> ;oLK H DHHB1p;o;o;oHrH5Ho;boH{H5Ho;EoHH5Hoo;(oH~H5HRo; oH|H5H5o;H@(nH{H5Ho;H@(nH{H5Hn;H@(@nH{H5Hn;H@( onHx{H5Hn;H@(HnHQ{H5Hrn;H@(!nH*{H5HKn;H@(mH{H5H$n;H@(mHzH5nHm;H@(mHzH5XHm;H@(hmHzH5BHm;H@(^mHgzH5-Hm;H@(7mH@zH5Ham;H@(@mHzH5H:m;H@( lHyH5Hm;H@(lHwH5Hl;H@(lHwH5Hl;H@(tlHwH5Hl;H@(@MlHvwH5Hwl;H@( &lHOwH5HPl;H@(kH(wH5H)l;H@(kHwH5Hl;H@(kHvH5Hk;H@(kHvH5qHk;H@(ckHvH5_Hk;H@(vH5<H?k;H@(@jHvH5/Hk;H@( jHuH5#Hj;H@(jH H5Hj;jHLH5Hj;fjHoH5Hj;IjHH5Hsj;,jHH5HVj;jHxH5 H9j;iH;H5Hj;iHH5Hi;iHH5Hi;iH4H5Hi;~iHrH5Hi;I^iE1LH H5 Hk;;iH}H5Hei;iHǑH5~HHi;iHjH5vH+i;hE1LoH x HH5\H=i;hHE1L:H C H5DHiH7  2Hσ;H*H=u΋;GhH5 Hg;HJ8 %hH5Hg;H 8 hH5 Hh;HPH H7 J gH5 Hg;HPH H7 J g1H5 Hzg;H Hz7 ugH51Hf;HH\Sg[]HA\Ef HHHHHJSON::XS: string size overflowobject is not of type JSON::XSincr_text can not be called when the incremental parser already started parsingexactly four hexadecimal digits expectedmissing low surrogate character in surrogate pairmissing high surrogate character in surrogate pairillegal backslash escape sequence in stringmalformed UTF-8 character in JSON stringunexpected end of string while parsing JSON stringinvalid character encountered while parsing JSON stringjson text or perl structure exceeds maximum nesting level (max_depth set too low?), or ] expected while parsing array, or } expected while parsing object/hashfilter_json_single_key_object callbacks must not return more than one scalarfilter_json_object callbacks must not return more than one scalarmalformed JSON string, neither array, object, number, string or atommalformed JSON string, (tag) must be a stringmalformed JSON string, tag value must be an arraycannot decode perl-object (package does not exist)cannot decode perl-object (package does not have a THAW method)malformed number (leading zero must not be followed by another digit)malformed number (no digits after initial minus)malformed number (no digits after decimal point)malformed number (no digits after exp sign)malformed JSON string, neither tag, array, object, number, string or atomattempted decode of JSON text of %lu bytes size, but max_size is set to %lu%s, at character offset %d (before "%s")JSON text must be an object or array (but found number, string, true, false or null, use allow_nonref to allow this)malformed or illegal unicode character in string [%.11s], cannot convert to JSONout of range codepoint (0x%lx) encountered, unrepresentable in JSON%s::FREEZE method returned same object as was passed instead of a new one%s::TO_JSON method returned same object as was passed instead of a new oneencountered object '%s', but neither allow_blessed, convert_blessed nor allow_tags settings are enabled (or TO_JSON/FREEZE method missing)cannot encode reference to scalar '%s' unless the scalar is 0 or 1encountered %s, but JSON can only represent references to arrays or hashesencountered perl type (%s,0x%x) that JSON cannot handle, check your input datahash- or arrayref expected (not a simple scalar, use allow_nonref to allow this)JSON::XS::filter_json_single_key_objectselfJSON::XSself, enable= 1self, v_false= 0, v_true= 0self, max_size= 0self, max_depth= 0x80000000ULklasssurrogate pair expectedself, cb= &PL_sv_undefself, key, cb= &PL_sv_undef'"' expected':' expected) expected after tagTHAWTypes::Serialiser::false'false' expectedTypes::Serialiser::true'true' expected'null' expected(end of string)garbage after JSON objectself, jsonstr= 0self, jsonstr\u%04x\u%04x%lu%ldFREEZETO_JSONnullself, scalar4.03v5.26.0XS.cJSON::XS::CLONEJSON::XS::newJSON::XS::boolean_valuesJSON::XS::get_boolean_valuesJSON::XS::allow_blessedJSON::XS::allow_nonrefJSON::XS::allow_tagsJSON::XS::allow_unknownJSON::XS::asciiJSON::XS::canonicalJSON::XS::convert_blessedJSON::XS::indentJSON::XS::latin1JSON::XS::prettyJSON::XS::relaxedJSON::XS::shrinkJSON::XS::space_afterJSON::XS::space_beforeJSON::XS::utf8JSON::XS::get_allow_blessedJSON::XS::get_allow_nonrefJSON::XS::get_allow_tagsJSON::XS::get_allow_unknownJSON::XS::get_asciiJSON::XS::get_canonicalJSON::XS::get_convert_blessedJSON::XS::get_indentJSON::XS::get_latin1JSON::XS::get_relaxedJSON::XS::get_shrinkJSON::XS::get_space_afterJSON::XS::get_space_beforeJSON::XS::get_utf8JSON::XS::max_depthJSON::XS::get_max_depthJSON::XS::max_sizeJSON::XS::get_max_sizeJSON::XS::filter_json_objectJSON::XS::encodeJSON::XS::decodeJSON::XS::decode_prefixJSON::XS::incr_parseJSON::XS::incr_textlvalueJSON::XS::incr_skipJSON::XS::incr_resetJSON::XS::DESTROY$JSON::XS::encode_jsonJSON::XS::decode_jsonTypes::Serialiser::Boolean`|x|x|x|x|x|x|x|x|x|x|x|x|`|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|`|x|x|x|x|x|H|x|x|x|0|x|x|x|x|x|x|x||x|x|x||x|{P{Ћh ՕTߖߖ֖–z;HƨbTܫܫyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy)tyyyTyyTTTTTTTTTTyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy)yayyyyyyyyyyyyyyyyyyyyyyyyyy)yaTԲT$@;d+JO UU@V$WHPWpYZ@[ ]L^aPc$epgiPlHnqPs,sHt\`tttzP|@~PЄ80 H 0 а `d p P0 h 0  zRx $(IFJ w?:*3$"DM(\XSFAH uAB4SAAD ~ GDI X AAA TAD } AE $THEAD {AA< T/FEE D(A0 (Q BBBH LVD0W E <hBBE A(D0J 0A(A BBBC @$KFEB A(A0D 0A(A BBBD H0FBE B(A0A8D` 8A0A(B BBBG @0FEB A(A0D@ 0A(A BBBD <tFEB A(A0c (A BBBG HBFB E(D0D8Gp 8A0A(B BBBF 0 ?BDA G0  AABI H4 BBB B(D0A8G` 8A0A(B BBBB H BBB B(A0A8G 8A0A(B BBBH 4 BAD GI  AABE @ pKFEB A(A0D 0A(A BBBF <H |FEB A(A0a (A BBBI , FAA v CEE GNUP$$@ UJZ  0 8 o`   H 8 oo8oooH  0@P`p 0@P`p 0@P`p 0@P`p 0@P`pGCC: (GNU) 8.5.0 20210514 (Red Hat 8.5.0-15)GA$3a1##GA$3a1GA$3a1GA$3a1#Y$ GA$3p1067`$GA$running gcc 8.5.0 20210514GA$annobin gcc 8.5.0 20210514GA$plugin name: annobin GA*GOW*GA*GA+stack_clashGA*cf_protection GA*FORTIFYGA+GLIBCXX_ASSERTIONSGA*GA!GA+omit_frame_pointerGA*GA!stack_realign GA*FORTIFY`$$GA+GLIBCXX_ASSERTIONS`$$ GA*FORTIFY$q%GA+GLIBCXX_ASSERTIONS$q% GA*FORTIFYq%9&GA+GLIBCXX_ASSERTIONSq%9& GA*FORTIFY9&&GA+GLIBCXX_ASSERTIONS9&& GA*FORTIFY&(GA+GLIBCXX_ASSERTIONS&( GA*FORTIFY(F)GA+GLIBCXX_ASSERTIONS(F) GA*FORTIFYF)|*GA+GLIBCXX_ASSERTIONSF)|* GA*FORTIFY|*K,GA+GLIBCXX_ASSERTIONS|*K, GA*FORTIFYK,-.GA+GLIBCXX_ASSERTIONSK,-. GA*FORTIFY-.0GA+GLIBCXX_ASSERTIONS-.0 GA*FORTIFY02GA+GLIBCXX_ASSERTIONS02 GA*FORTIFY24GA+GLIBCXX_ASSERTIONS24 GA*FORTIFY46GA+GLIBCXX_ASSERTIONS46 GA*FORTIFY6'9GA+GLIBCXX_ASSERTIONS6'9 GA*FORTIFY'9;GA+GLIBCXX_ASSERTIONS'9; GA*FORTIFY;=GA+GLIBCXX_ASSERTIONS;= GA*FORTIFY=7@GA+GLIBCXX_ASSERTIONS=7@ GA*FORTIFY7@BGA+GLIBCXX_ASSERTIONS7@B GA*FORTIFYBBGA+GLIBCXX_ASSERTIONSBB GA*FORTIFYBBCGA+GLIBCXX_ASSERTIONSBBC GA*FORTIFYBCCGA+GLIBCXX_ASSERTIONSBCC GA*FORTIFYCCGA+GLIBCXX_ASSERTIONSCC GA*FORTIFYCIGA+GLIBCXX_ASSERTIONSCI GA*FORTIFYIKGA+GLIBCXX_ASSERTIONSIK GA*FORTIFYK NGA+GLIBCXX_ASSERTIONSK N GA*FORTIFY NPGA+GLIBCXX_ASSERTIONS NP GA*FORTIFYP TGA+GLIBCXX_ASSERTIONSP T GA*FORTIFY T#lGA+GLIBCXX_ASSERTIONS T#l GA*FORTIFY#lnqGA+GLIBCXX_ASSERTIONS#lnq GA*FORTIFYnqrGA+GLIBCXX_ASSERTIONSnqr GA*FORTIFYrn{GA+GLIBCXX_ASSERTIONSrn{ GA*FORTIFYn{*~GA+GLIBCXX_ASSERTIONSn{*~ GA*FORTIFY*~ GA+GLIBCXX_ASSERTIONS*~ GA*FORTIFY GA+GLIBCXX_ASSERTIONS GA*FORTIFYߋGA+GLIBCXX_ASSERTIONSߋ GA*FORTIFYߋGA+GLIBCXX_ASSERTIONSߋ GA*FORTIFYGA+GLIBCXX_ASSERTIONS GA*FORTIFYGA+GLIBCXX_ASSERTIONS GA*FORTIFYkGA+GLIBCXX_ASSERTIONSk GA*FORTIFYkLGA+GLIBCXX_ASSERTIONSkL GA*FORTIFYLGA+GLIBCXX_ASSERTIONSL GA$3p1067##GA$running gcc 8.5.0 20210514GA$annobin gcc 8.5.0 20210514GA$plugin name: annobin GA*GOW*GA*GA+stack_clashGA*cf_protection GA*FORTIFYGA+GLIBCXX_ASSERTIONSGA*GA!GA+omit_frame_pointerGA*GA!stack_realign GA$3p1067##GA$running gcc 8.5.0 20210514GA$annobin gcc 8.5.0 20210514GA$plugin name: annobin GA*GOW*GA*GA+stack_clashGA*cf_protection GA*FORTIFYGA+GLIBCXX_ASSERTIONSGA*GA!GA+omit_frame_pointerGA*GA!stack_realign GA$3p1067##GA$running gcc 8.5.0 20210514GA$annobin gcc 8.5.0 20210514GA$plugin name: annobin GA*GOW*GA*GA+stack_clashGA*cf_protection GA*FORTIFYGA+GLIBCXX_ASSERTIONSGA*GA!GA+omit_frame_pointerGA*GA!stack_realign GA$3p1067##GA$running gcc 8.5.0 20210514GA$annobin gcc 8.5.0 20210514GA$plugin name: annobin GA*GOW*GA*GA+stack_clashGA*cf_protection GA*FORTIFYGA+GLIBCXX_ASSERTIONSGA*GA!GA+omit_frame_pointerGA*GA!stack_realignGA$3a1GA$3a1GA$3a1GA$3a1,`$n;mF aF-`$8h8f$48Y @8<8<8h$ %48\0_'@nint))L8<@S%LL\Sa SEL+S$'96(3o#/7 2B! q#f8o$q@%O2lN3#< S;  A SS8   8 # Z @ R< T#<B U#<  V %<( v: x^$ yLD z |L D@ p mG m/ B8< 1L1( C & ENL6 F$ G qS'/ H8  aat!)pZS /"h#p.$x"1'S 2  G S x# *! X" !:(S !])@' ( @T)H(mSW/S]\[D /Ey;8=: "+;;?A (B XC;G1=I "+JXK; O|=Q "+RS DT80U;a`c /a.d /1^ e|1 g; Y<[ / ]mx1h ;l[Fn+o ;tHXv /;w  xL 1p35$<:DX_rtLM;V16iGp/AyS;$ 1& |( [* 0 D8{ H|A../   JS@: *J *J t#ipA fC!#-$fD2 >;7 ; 8cq @ 38AE qS #25   #*2I5 5#?2i7J J#T2o_ _#i :s=w5_ l:D k t t#&+ N?_ @D %@ # 2} + + #5 2@ @ #J 2.U U #_ 2<j j #t 2X@  # 2  # # %# :# O# d# #  # 0 # E # Z # o #  #"  #- |&@ m:_ !8 {41  rA {B ( S4 S@ S D  k  5  4 S C. ZB0 65 v=A>F@ W,A C $$E (J 08N68*PB@[H 4\X&]hK3j xZ Sf SxD 3 zD 4  4 A6 &7  W #  -f9.f 8    f%A  P >  @ !b3 !!d f!!e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 0/L1cF/Mf8/M2&/MJ"6/M+2W2/M+2,/M+2 KA/M$//M1(/M1)BI80ZBU8041BI160m1BU160@ 2BI3202BU320L+2s+272L2<A2@0L20< +2Av2/ k24$w 60E$y  $2 22 $' .% {% 82A22/  2 BD11s491316 f]17 f;18 f8519 f /1: f(1; f0'1< f8C 1= f@1@ fH1A fP1B fX11D4`B1F4h21Hp1Itz+1J x71M@ 1NZP#1O4:1Q4WC1Y !1[4,1\4C1]4<1^ /D1_ v*1` 1b4FD22t1+2R 4 2q4S 42! 42) 4q4S34 s4.234 3404 5< 54504 455<J525>[5 >55Nn52s674\175>7 2M+7 fL+7 2J17 2175ZL)>6 (   Z# $ <=  *  Z8 + 4   H 8  SB)5BHE)U6Che- 69-$ 8-% <-)BQBHEK)6Chek --6~2-.+2b-/29-541)L7B)f)s)%)a)2h)8@)2 )85)8 )8 (.88v382c*8<88r?+(8P@ A8g?(+8207A8+28'8@t8H8PE>8V@X,8+2`U>8+2dd68/h 8+2pM08+2t 8\@xq 8 8fT"82-8E8 8j#8-q#8L-.8L k 8= L7 8 J6 i& O51)l9B)f)s)%)a)2h)8@)2 )85)8 )8 +1)9B)f)s)%)a)2h)8@)2 )85)8 )8  ,1)|:B)f)s)%)a)2h)8@)2 )85)8 )8 +1);B)f)s)%)a)2h)8@)2 )85)8 )8 a+3);B)f)s)%)a)2h)8@)2 )85)8 )8 ,3)*<B)f)s)%)a)2h)8@)2 )85)8 )8_.)m<H) u8) 25) ^2D) 2_A)<-) so5) C) <) 2 6_G)<+) <N))  (3) =!)W)f3)/=!)W)f3)T=!)W)f3)y=!)W)f3)=!)W)f3)5=!)5W)5fm6): +2A=2= % = 03)_>!)_W)_f3)l<>*)m<>&?)n / b;M><B>*9M> 8>9818 1f58 28^> (8&>8' 8( 8) 28* 2 8+  d8-?98. 1&8/?>&?S :68:[?<#8; Qend8< !8C :68D&? &g?18?!8W8f $(h8K@@8@Q8@E8 [?(.8L7 8@78 8@ b28n@.g?@22+2 @.2@2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+@L 24@M 2!2@N 2@O]@P 2(@Q fA@T fA@U f@V fE@W f@X f@@Y f)@^ ^2`5@_ 2)@` 1t@a 1/@b 2!@c 8fE@d 2:@f !]@g 1]@>@h 1T)@i 1U4@j 1V@k 1W8@l ~VX@m `C@n ^2`>.@o ^2d:@rshE@ssp@tqx'&@v2y['@xLx[@yLx[@zL x[7@{L xI*@}2{p@~ 1| PY X DY51]S2A]SC@PY / M]2c Y]&$]$2$$]B$$] d]$Q]] ].]2,$R] ]A]22f$S]^>$U^  ^.2!^22$V.^ 4^A?^2xJ^<?^;$uJ^a=$wJ^$yJ^${J^$}J^$J^$J^;$J^$J^A0$J^5$J^ $J^x^S^!$^2$$J^<$J^}$J^ ,$J^">$J^$J^4/$J^#"$J^L $J^$J^Z$J^e$ 1'$$ 1$ 1x_S@_$_W$J^x`S_ $`b$`T$59`<.`!9$9`s!$M>Z<$M>$M>*-$M>4`<$`.$M>`<?$`^ $J^v,'L$a  Q > c' 6 3 '\$5&/BH$F1apad$G1a$AaS&$PNa TaAda22N8$aqa wa.2a222t($fK $ga a.2a22d$hNa.$ia a.b2f>fS.fy<C>f._fSOfC _f1fSpf$N f2f<f &$bf$cf $df$ef-$ff:$gfZLDh R > >   > = "  d@ ' m c% x   "  62      52     4 A 0 ;( $! 5" # z/$ % %& ?' b/( ) E?* + v,, - -. +/ ,0 +1 82 3 84 5 6 G'7 8 F'9 : %,; S9< R9= >> ? s @ EA &B 3+C d?D E F G H 7I EJ xK3$ZhEnv$ZEu8$Zhh1hS.$Zh3$[/iEnv$[Eu8$[h i$[/iS+_ 2 @ S_2 8 S ` 2 0 S`2 ( Sp1a 2  ZLci - ? 4   ;! E! 3;Hp j9q+2;?r+2Vs iu2=v2D)y2 Fz (({0r*|44!~28'~2@3ij/p jcur fend fsv2!jD2+2`hk j/h bkcur fend ferr!jZ;+2`+2d])kZkS@=&%ok  wA$ P[}%  2!cv ==+   ax 2"'0 2sp 2'^ 2@YA  V[l _p /~Wyl _p /0Wl _p /`Wl _p /Wl _p /Wl _p /97Wm _p /^\ X-m _p /PXKm _p /Xim _p /Xm _p! /Xm _p# /Ym _p% /<:@Ym _p' /a_pYm _p) /Yn _p+ /Y;n _p- /ZYn _p/ /0Zwn _p1 /`Zn _p3 /?=Zn _p5 /dbZn _p7 /Zn _p9 / [ o _p; /P[+o _p= /[Io _p? /[go _pA /B@[o _pC /ge\o _pE /@\lq i 0] p _p /xv7 7T _Q0 .\sp!.=\-.7 17T Q1 .L\p!.=\-.  Q7 e7T Q1ٸ77 qT Q177>qT Q17 7T Q0f77qU  Q R X 7777rT Q `$7Ա7GrT Q @@۱77rT Q 277rT Q 07+7rT Q 0.<7R7+sT 6Q 0.c7y7dsT MQ 0.77sT bQ 0.7Dz7sT zQ 0.ز77tT Q 0.77HtT Q 0.&7<7tT Q 0.M7c7tT Q 0.t77tT Q 0.77,uT Q 0.³7س7euT Q 0.77uT Q 0.7&7uT $Q 0.77M7vT ;Q 0.^7t7IvT JQ P,77vT fQ P,7´7vT Q P,Ӵ77vT Q P,77-wT Q P,!777fwT Q P,H7^7wT Q P,o77wT Q P,77xT Q P,7ӵ7JxT *Q P,77xT @Q P, 7!7xT UQ P,27H7xT oQ P,Y7o7.yT Q P,77gyT Q ;77yT Q =7ж7yT Q 09׶77zT Q 67 7KzT Q N7'7zT Q P.7D7zT Q pK7a7zT !Q 0~h7~7/{T 2Q p{77h{T JQ r77{T _Q *·7޷8{T Q|R sX077|T zQ 477W|T Q I757|T Q K<7c8|T Q  R X Y0j78@}T Q pqR X Y0͹7x۹8( pqKy%  2E A !cv = ~ +   sp 2 ax 2 0 27 3 ^ 2 )~? 2 )~@!P j 9.qP*Q h~F.& $ `P*&r76r~~UvTwQ0@r7Jr7r7 r)8TvQvR1q7er7 /qP) #&/K I q7q7q7r68 r@8U~T z(   K%  2r n !cv = +   sp 2$  ax 2 0 2d`^ 2@U  2U@!F j 9.VG F.SQ`V֮7UvTw77?7 R)8TvQvR177 /[U <&/xvQ7[7q7\68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 (%3(^Z( =,T}Q1{(XH'((4(XX=((,*(a4(SO( u,T}Q1 0HPpH"pH;7 (bH!(((@((DB ,T~Q}4/nn /ig// {:T Q} HF {(I.b(VR((I(( (У8(D@(|z ,T}Q1 'J3 ('PJ (((0(SO( ,T}Q1{(J((4(@((" (7(IE( *,T}Q1hJ1hJ" (hK&((XT(P0(( e,T}Q1{(@K'((4(@(:8(`^(7(( ,T}Q1 Q R"51 (`R&(ok((M/(( b,TvQ1{(|R'(-+(SQ4(||9(xv((0(( ,TvQ1 R- 9S^Z"S (B0S((0,(2(hf( .,TvQs4/KK/// [:UvT Qs7(:ATs7+:kTsQ0š1UT|H|ߡ;U7+:TsQ07ƣ&;TsQ|g8U 688;S?I'P),%!ai&"!b)iq_)7h)3;R2)7*@;T~QsR|*7A*@; T~QsR}U*7m*7IK2w@&H!a_wi62!b_w*iso cmpy a{8 b|8 la~ ! lb YW|&M;?\1*enc\_*he\8,svb 2lencstrd f?9*enc9_*av92i;len; ,svpH2??,*enc,_?"*enc"_?*enc_?=2*enc_,'  ({(!enc_|!strf' !len+>8%z04 end f.' ch4n@/$@X' uch ],/!,x,ZTn,b],̄@0,x,n,/-ӄ7 :TsQRX@<$ (Ă0"(XR((B(( *,T (σ0"(D>((H(( ,T j/ۃ0"/A?{/om Y;T1Q R  (\01\#(((B("(\Z ,T 6,e`1"#Q,G,|6,@@@Q, ~ G,   (1K$(  (6 2 (w>(p l (   ,Tg8p$U Ts g8U  (ɀ1%(  ("  (`>(\ X (   x,T (2%(  (  (%>(H D (   =,T (e02&(  (  (:(4 0 (n l  ,T (`2|&(  (  (Ɇ:( (ZX ކ,T (2&(}((:( (FD ,T (%2t'(oi((=:((20 R,T(e2([U((U:(( j,T (A.m((IA((7(@<(xv &,T~Q|68?](*enc_*chq? (*enc_*len,curbuf fJj)a j2ICU%)!svU2 svtW >6)Flen[` pv\ fVT&7 )&8TsQwR29&68IRA(*!sAy@C`@,D\ negE)*V*UUT`Q\R0X:1)*{*UU#R0X:F)68} 8&/,iscO%,O,1bO;OG'jQ/!j+ dig 1m+ _W neg'*+T}Q|R1(*+T}Q|R0 D(*T}Q|R1 &'d;a -$@ KO6,>sv26XCfKb],>s>ch#K ,>s>len'6X'4S~'f$-isv2F:O:O:+c-$` I---#=`- q%g8U c-$ --b\-=-0%7D%9TUK#->l1>l2dsum em(.>sv 2,kKu229.688dsv2e3_.6!Ɔk3jJtE.*s.*off$ 1Jzos.a o2*ao$.*bo1.e.6 2>sv2,drc+2KsE2/>sv2Kw23/6  2UAj/>__sAl>__nA6iAlU"/>__s"l6i"lU%>//684>/6>6!>U'/0684'/6b'i6!'U/7068416bo6!V.B60!.-.QOB7 B7TsQ1V7Br0$I$IV~tb$  n  z   !!GV(PCF21$($(C)V ,CP1),u!i!$,$,c.C 1."!.V"L".""hC81QT C8TvQsC7V?7 ##$ {( 3^2(p#l#(##(`3(##(9$5$(Ȋ8(s$o$($$ ݊,TvQ1)3^3 $$gP"%%) 3Us78<3TvQwR27 :Tv {()3n4(F%B%(%%()4(%%(%%(?(4&0&(l&j& ,TvQ1 {(J@4q4(&&(&&(Jp4( ''(G'C'(d<('}'('' y,TvQ1  4r)!6'' ( 4g5((((V(R((p0(((((( ,TvQ1{( 5(((())4(:(9)7)(_)])(1())()) ,TvQ1 @P5p)7)) (@56(**([*W*(0(**(** ,TvQ1{(05(**(++4(00@(>+<+(d+b+(97(++(++ J,TvQ1ԉ7Usߋ68E` F# # F,,F{F 44F;;F/ PF99F2  F''Fn KDKD>>Fb''FF K7K7F zzFF ==F DDF W GFh P F77Ft --F ggFG"G"F FDDF++F F 7<7<F --Fz 77F F1 BBF L/L/Fz4z4F**F F PPF! F 7 7 F FP ((FU 11FY(Y(FLLFB F77F--F@@FEEFPlDlDFF%%FEPw w F))FFFPFyyF6WG((F ..FW%%Gn0n0FW*D DG HqEEIH; ==F$$F ;;F PxxI@ WMCGpowpowJB1 : ; 9 I8 1B : ;9 I8 1 : ;9 I841B 1  I ( 1RBUX YW  4: ;9 IBI : ; 9 I : ;9 I4: ;9 IB U4: ;9 I?< : ; 9 I8 1.?<n: ;9 : ; 9 II4: ;9 I&I1RBUX YW 4: ; 9 I?<: ;9 I : ;9 I8 !I/  : ; 9 !: ;9 IB" 1U#7I$1%: ;9 IB& : ;9 '4: ;9 I(.: ;9 '@B) 1U*: ;9 I+.?: ;9 'I<, - : ; 9 I 8 .'I/ : ;9 0 1 : ; 9 2<3 : ;9 41RBX YW 5 6: ; 9 I7 : ;9 I 8 8$ > 9: ;9 I: : ;9 ; : ; 9 : ; 9 I?.: ;9 ' @4: ;9 IA'B: ; 9 IC : ; 9 D1UX YW E : ;9 IF4: ;9 IG 1H1BI.: ;9 'I@BJ.: ;9 'I K.: ; 9 'I L1RBX YW M1UX YW N1X YW O: ; 9 IBP.?<n: ; 9 Q : ; 9 I8 R!I/S4: ; 9 IT 1U.?: ; 9 'I 4V.1@BW.?<n: ; X : ; 9 IY : ; 9 Z> I: ; 9 [ : ; 9 I 8\ : ; 9 ] : ;9 ^ : ; 9 I8_ : ;9 ` Ua: ;9 Ib1RBUX Y W c1RBUX Y W d4: ; 9 Ie.: ; 9 ' f : ;9 g41hB1i: ; 9 IBj4: ; 9 IBk4: ; 9 Ilm% n$ > o p&q : ;9 I8r : ;9 s5It: ; 9 u : ;9 v> I: ;9 w.?: ;9 '@BxB1y4: ;9 I z : ;9 {1X YW |1RBX Y W }.: ; 9 '@B~.: ; 9 'I@B41B1.?<n.?<n: ; 9 Hv: /usr/lib64/perl5/CORE/usr/include/bits/usr/include/sys/usr/include/bits/types/usr/lib/gcc/x86_64-redhat-linux/8/include/usr/include/usr/include/netinetXS.cinline.hXS.xsstring_fortified.hstdio2.htypes.htypes.htime_t.hstddef.h__sigset_t.hstruct_timespec.hthread-shared-types.hpthreadtypes.hstdint-uintn.hstdint.h__locale_t.hlocale_t.hsetjmp.hsetjmp.h__sigval_t.hsiginfo_t.hsignal.hunistd.hgetopt_core.hsockaddr.hsocket.hin.hstat.htime.htime.herrno.hnetdb.hnetdb.hdirent.hdirent.hperl.hmath.hop.hcop.hintrpvar.hsv.hgv.hmg.hav.hhv.hcv.hpad.hhandy.hstruct_FILE.hFILE.hstdio.hsys_errlist.hperlio.hiperlsys.hperly.hregexp.hutf8.hutil.hpwd.hgrp.hcrypt.hshadow.hreentr.hparser.hopcode.hperlvars.hmg_vtable.hoverload.hpthread.hproto.hstdlib.hstring.hmathcalls.h `$K  =s !<Xo#  o<J . <X ~f   pr z.q  fu<[  fY Ig =  tJZKXp.tt %Y; rX>Z'J    g = WZX YvJKz _;=I KIMJ 9= >JK-Y[f|zJB .L-J:L;K <V>  L <J-XXL  K ...9ft sX KYJ U<J$<vXH. f&J<I$<<iJJ uY P.KXJ/ Et < < IX <zJK $]<HL$<t1JCu5gx OK !fJ J J = s 2  7tX.K  XXjX#  j.J < X JJ<K b  X .*8[5& \ 5u~ft!-K - KJfX ~. ~X<JJ.JnXJ<NtJ< XX*o ~X s 4K  XXjX#  j.J < X JJ<K c  X .*8[5& . }f KffX }. }X<fvX f<f t" }* t ;K  XXnX#  n. Jn< < XtJuJ Bfy P<z> X .*8[5& W }f KtfX }. }X<fv!f<f!t }* t =#K  XXmX#  m.J < X JJ<KeX X .*8[5&  }X)JJ}Jt X. ,XLn*(  ( yu @@~K  XXoX#  o.J < X tJtL#&>J#&>J#&>X#&>XK GM= F>j>r<t<  zX >  w.<Z  < oJ! J]E 2=yf~ 2zX9Jz 9  z2Jz<  ' >9/ yX y  < fJ<  J LJ  >  < Lt v   vJ  < v<  t KI<   K J<MMYI=J .J$ t ? >   ֐(/9<,JJJ(/9<,JJJ(/9<,JJJ(/9<,JJJ(/9<,JJJ$2.!J.JJ6 K =%J tJ<\.x v  tX xX=<>KX 5%"M%M"Y%K - t!8 x  iJ xJgt<gt<gfhf!xw >J xJgt<gf g  xtXSKtXxX   "LXXTtX XtX]tXXXx = X .*8[5&  \*   J <}JJptYK X O) J< X .*8[5&  \* | X J <|J i  f $J'ff J |X X|t g <. L  J X<  -fX |. |X<f|ZpXf <*|JptYKY{ J=np   J=7. imt  L {=Xp   =fm<J7.tX=<< ttK f t mJJKXtL kXJ=JKv,>tX=<< ttKD.D<X > tYY t>X}"K $  t4 t-;}r  <)X,*;  u  KX . J < < 1   t k<Jz qK I =;)r  <)J J <t<J7~ u qY I =s)X qY I =s)JttJ.tX  /;tX*  H v#! L|ּ t   L :v<l<XwX r<J ~tJ} t<Jw | qg I =s)J q I =s)JyX  ftw+=f tfK-Jq? tX? .?<X>uYY < fX ~XX Xvl< X `fJ-=XxX t/ Xf- ? GM!XX"fh : JYx cY g >y=Jim   X=7. iJz<  ZXJJ0tt.* 0X Z*X. yJ=fp.   X=7. imt  Z J  sX=<< G? XI==u)Lr#.IsJ f \-tytrJ W =;)Jzr W =s)XXXX#w(st /s .XXiX#  i.J < X tJfL< zXn.J zn X n KXz<=X.=< Y=- =J z.J zX<f... zJ.nX r} Ks .XXkX#  k. Jk< < XtJuJ Bfy P<z> X .*8[5& 8if<X{ J ) X K.J     %J"Xt.l!!tL+tnJ n<  < XoaJX< =J[JX<&=J ..JfJX<16:XJ:J=JE<INJQX<_KX<15:XJ:J=JE<INJQX<_LX<14:XJ:J=JE<INJQX<_MX<13:XJ:J=JE<INJQX<_NX<12:XJ:J=JE<INJQX<_=<$'=;K$s'=$J5'tu$J;Bt'<g$J;Bt'<g$JB'fiX'JuYIJK(<*<|B/- |tBX:e |J#$XXX'JuYIJK(<J #ZJ3}f+< I+<<#XX ~Xv  t ~f<gtA'Ju<(tt X} =IJYX f 'KYY(JWJK(<J-$J)'J0'KY(JWJK(<'JKYI<K(<'JKYI<K(<'JKYI<K(<'JKYI<K(<'JKYI<K(<'J<KYIJK(<~ >HJYt<gX'KY(JWJK(<~ u ?GJYt<gt<gXhXQX ~<~r  t<K "~r<  t<~r<  t< t0/J~r<'KWuYIJ=(<.)~<  t)~<  t<~r<'KWuYIJ=(<(~'KWuYIJ=(<'KWuYIJ=(<J~rKW=YIJ=(<'KWuYIJ=(<J~rKW=YIJ=(<f=; !|r<  J |<<<u|r<  t<A$0   - s .  ={ I<2K%;=%- = 1  mXJ..J<WJ.X5<WE<>J=>-U< <J.<J<WJ.X5<WE<>J=>-U< <J.<J<WJ.X5<WE<>J=>-U< <.5fJXW<>XW<><U< .<5X>     fX .{/<q 6{  ytyJ tt+~X>     tt J,X|'KWuYIJ=(<'KWuYIJ=(< J>  < /  tf J ,J(}'KWuYIJ=(<    tt J ,rX|'KWufYIJ=(<Ȑ'KufY(JIJ=(<} >~r<  t<^ LJ  Df <   YZ~r<  t<< Kh~<  t ~< <~JJ~<<|    9bq~<  tMt1'J~r  tJX X.K<e|'J=WKI=(<~  tJ'f ~J<~<|    ~<  >1( H>  KI9GKV? %I =X?<f |r<  t< |r<  t< ? ?  X|r<  t< |r<  t< |r<  t< \%J0,<|r<  <<*^ |r<  t< X|'KKYK(JWJ=(<@3( H>  9G?U@KJt I KZc ?|'JuXIJ=(<'KWKI<=(<)|'KWKKI<=(<J~rKKI<=(<p.Iuptv X ,s uX w.<tZ0>,wX.-~>=\D\%~~ $ &3$p"!~ $ &3$p"!,P(]D~]]%]C_D_PUUT$]$GTGq]qT]\^^^~VGVV~~ $ &3$p"~ $ &3$p"|~ $ &3$p8-VV@\q\ p}"## p}"##- v  v  G1P0NUNU0RTR_vTv_X}V}vx=V=BPBVqv^v~\v\v~v}~ $ &3$p"}~ $ &3$p"P\]]]B]Q_B_\fP]qPU UT_ T _c]c5 \5 L |S \ P \ ].3\3_|_ V V |3=| $ &3$p"=E| $ &3$p"3=}| $ &3$p8AP ^S ^3j Q J VS V.P U g U T [ \[ X TX g \ 1 V1 6 vx[  V  P g V % ^% U RU   ~[ k ~k ~ ' ' X ~X f Rf g 4  ][ ] ] g ]8  _[ _  _ g _4 < P< U |X f |  R[ r Rr   P  Pp U ,Up T ^ T ,^ V v vx V p V P,V ] } \ \\,} } $ &3$p" } $ &3$p" v} $ &3$p8 \ \ P0NUNU0RTR_T_XVvxmVmrPrVq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)((p))((p))(())(())))))))**"*%*(*}++,*++,+++,],],_,c,f,q,,,,,,.////P/T/ //[/p///`/p///000Q0Q0p0p00566J6J6e6e666666677>7>777778828288(9P9;=?0@@@AABBB1CCCCCCC EFFFFG000"0&0)0>0Q0Q0_055(9P9BC>0D0BCw00B0B|00B0B5555566J6J6e6e666666;7>7777778828288@@AA0BBCCCCCC EE55566J6J6e6e66666677@@AACCCCCC EE5566069677@@55@@F6J6J6e6e6q6@@6666AACCCC EE777778828288?BB777778?BmB8882828>8mBB6667x77?@777;7>7J7@0@><=FFF1GjGxGf<<G1GEFFF1GjGxGGEFFF1GjGxGGEFEG\G011*1*1j1j11111111P9}9}999;;;;;;;;;=`=>>`@@@@@@@@@AAAABBB1C]CCCCCCvDDDD E00011*1*1611C]C00011*1*1611C]C009C]CX1j1j1y1P9Y9>>`@@X1]1>>1111@@BBCC11BB11AABBBB11BBBBf9u9y9}9}9999D2Df9u9}9999D2Df9k9D2D9;;;;;;;;;=`=CD2DvDDDD E`::DD;;;;D E;;;;DD;;==1244=>>?0@`@PAABB]CpCCCvDD44=>>?CCvDDO??vDD22233,3,3333455*5*558(9`==AABB222222233,3,383'5*5v55BB23BB@3P3P3333455'5*5v58(9AA@3P3y333344`5v588@3P33344`5v588J3P388555'5*5658(9%H>HLLI&I&INIQI_IPLLI&I&INIQI_IPLL I&IdLLJJJJJJLLJJLLJJJKLMK LLLKLLLKMKMMM\MMMMMMMMN(NGNMMMMMMMNNN(NGNMMMMMMNNNNNNNNNNN'RPRVEPPPRRHThTTTPPPPPRRS T0ThTTTUU`VVVVV QRR0S4SXNXXXXXX YYXXXXPY`YYYYZ-Z3Z3Z6Z:ZA[P[[[[[[``[\\.\7\\\`` d%d6d[[[\&\*\8^_>__```ac d%d6d[[[\#`[``````[[[\`````W^p^aab_{_6a~a{_{_____`acca-aUccc daacUc`\u\_>_\\_`\]/bib8]Q]ibbx]]bb]]bc]^a/bNdQdadudhffNdQdadkdhffdd0e`e@fhfddteeddteedee@fdde@feeeeg@g@gzgeeg@gee@gzgeeeefffgeeffeefgg,hPhhkkggggkkggkkh,hkkh"hkkhi(nknhh(nkniijkklmmkn>o>oooooppqqvv8w8wyw~w@x@xxx{{{ |H|iiklp`p"qtatuPvyv~wwxzz{ |:|SqswwxyyzzO{qqyyrrayyrrayyrr'yayrr'yays4szLzs*szLz4sKszz4sAszzKsbs]zzKsXs]zzgsswwsswwsswwssyzssyzsttu~wwyyO{{tuyymm{{kn>o>ooooop`pppqq"qtatuPvyvvv8w8wyww@x@xxxx:|H|nnuvnnuvnnqqq"qyxxxxqqq"qyxxxxqqyxxq"qxxn>o>oooooo`pptatyvvv8w8wywnn`ootat`ootat`ootatcofojonoqo}otato>o>o`ooooooo`ppyvvv8w8wywo/o`ppo%o`pp>o>o>o`ow8w8wyw>oKow8wKo`o8wywooooooyvvvwooyvvoovwooppppx@x@xyxppppx@x@xyxppx@xpp@xyxoopqwxpqwxppppwxopvPvoovPvi jlm`jjjm(n||||||||=}I}0Ņ50Ņ5Ņ05P}X}}(~@}(~@}}}}~~@}}}}0p `}}p}}p}}}}}}}}0 ` 0 `(~0ƀƀ @` UŅ5hh؆؆~0ƀƀ @` UŅ5hh؆؆T` @؆؆ @؆؆ -؆-@؆im z z zzƀƀ @ UŅ5hh ƀƀƀ5hhƀӀ5hӀh @UŅ -U-@Ņ0>UUUCP'20H||0H||H|0|؈00044H00044H /5559|؊AGO|؊CGOT^m779Gmssvz݌ˍˍ͍Ѝ@@BEggil܎܎ގ**,/QQSVxxz}ƏƏȏˏ;;=@bbdgאאِܐ%%'*LLNQssuxÑƑ18@\^h{єӔޔєӔ 68F\^a8` 8    # @`0 8 @ H H  H`  `$ ! #3 #I #` #{ # # # # `$ $ `$'@ 28 =0 H( R $n q% $ q% 9& % 9& & @&H &: (W &/g ( F) ( F) |* P), |* K,) *? K,d -. P, -. 0 0. 0 2I 0h 2 4 2_ 4 6 43 6[ '9 6G '9 ; 09U ; == ;US =| 7@ =G 7@ B @@N  B! B7 B6@ Bb BC Br  BC C PCF C: Cc CP C I C I K  I  K@  Na  K}u  N  P  Nu  P'  T^  Py  T  #l  T    #l  nqV  0l>  nq%  rJ  pqKb  r  n{  r  n{  *~  p{-  *~O  o  0~       ߋ  ?  ߋ*  A  K  U  n         k K k? L_ pr L  # # $ 8  P$"0 A\O U@ bH k@~ H    5H_t  ,9K_v P 4GWdvH  *;KW cr&=HXiu "!3KWr.annobin_XS.c.annobin_XS.c_end.annobin_XS.c.hot.annobin_XS.c_end.hot.annobin_XS.c.unlikely.annobin_XS.c_end.unlikely.annobin_XS.c.startup.annobin_XS.c_end.startup.annobin_XS.c.exit.annobin_XS.c_end.exit.annobin_XS_JSON__XS_CLONE.start.annobin_XS_JSON__XS_CLONE.endXS_JSON__XS_CLONEjson_stashbool_stashbool_falsebool_true.annobin_json_sv_grow.start.annobin_json_sv_grow.endjson_sv_grow.annobin_ref_bool_type.start.annobin_ref_bool_type.endref_bool_type.annobin_he_cmp_fast.start.annobin_he_cmp_fast.endhe_cmp_fast.annobin_json_atof_scan1.start.annobin_json_atof_scan1.endjson_atof_scan1.annobin_json_atof.start.annobin_json_atof.endjson_atof.annobin_he_cmp_slow.start.annobin_he_cmp_slow.endhe_cmp_slow.annobin_XS_JSON__XS_incr_text.start.annobin_XS_JSON__XS_incr_text.endXS_JSON__XS_incr_text.annobin_XS_JSON__XS_get_ascii.start.annobin_XS_JSON__XS_get_ascii.endXS_JSON__XS_get_ascii.annobin_XS_JSON__XS_ascii.start.annobin_XS_JSON__XS_ascii.endXS_JSON__XS_ascii.annobin_XS_JSON__XS_get_boolean_values.start.annobin_XS_JSON__XS_get_boolean_values.endXS_JSON__XS_get_boolean_values.annobin_XS_JSON__XS_boolean_values.start.annobin_XS_JSON__XS_boolean_values.endXS_JSON__XS_boolean_values.annobin_XS_JSON__XS_incr_skip.start.annobin_XS_JSON__XS_incr_skip.endXS_JSON__XS_incr_skip.annobin_XS_JSON__XS_get_max_size.start.annobin_XS_JSON__XS_get_max_size.endXS_JSON__XS_get_max_size.annobin_XS_JSON__XS_max_size.start.annobin_XS_JSON__XS_max_size.endXS_JSON__XS_max_size.annobin_XS_JSON__XS_max_depth.start.annobin_XS_JSON__XS_max_depth.endXS_JSON__XS_max_depth.annobin_XS_JSON__XS_get_max_depth.start.annobin_XS_JSON__XS_get_max_depth.endXS_JSON__XS_get_max_depth.annobin_XS_JSON__XS_new.start.annobin_XS_JSON__XS_new.endXS_JSON__XS_new.annobin_get_bool.start.annobin_get_bool.endget_bool.annobin_decode_4hex.isra.1.start.annobin_decode_4hex.isra.1.enddecode_4hex.isra.1decode_hexdigit.annobin_json_nonref.isra.5.part.6.start.annobin_json_nonref.isra.5.part.6.endjson_nonref.isra.5.part.6.annobin_ptr_to_index.isra.9.part.10.start.annobin_ptr_to_index.isra.9.part.10.endptr_to_index.isra.9.part.10.annobin_decode_str.start.annobin_decode_str.enddecode_str.annobin_XS_JSON__XS_incr_reset.start.annobin_XS_JSON__XS_incr_reset.endXS_JSON__XS_incr_reset.annobin_XS_JSON__XS_DESTROY.start.annobin_XS_JSON__XS_DESTROY.endXS_JSON__XS_DESTROY.annobin_XS_JSON__XS_filter_json_object.start.annobin_XS_JSON__XS_filter_json_object.endXS_JSON__XS_filter_json_object.annobin_XS_JSON__XS_filter_json_single_key_object.start.annobin_XS_JSON__XS_filter_json_single_key_object.endXS_JSON__XS_filter_json_single_key_object.annobin_decode_sv.start.annobin_decode_sv.enddecode_svsv_json.annobin_decode_json.start.annobin_decode_json.end.annobin_XS_JSON__XS_decode_json.start.annobin_XS_JSON__XS_decode_json.endXS_JSON__XS_decode_json.annobin_XS_JSON__XS_incr_parse.start.annobin_XS_JSON__XS_incr_parse.endXS_JSON__XS_incr_parse.annobin_XS_JSON__XS_decode_prefix.start.annobin_XS_JSON__XS_decode_prefix.endXS_JSON__XS_decode_prefix.annobin_XS_JSON__XS_decode.start.annobin_XS_JSON__XS_decode.endXS_JSON__XS_decode.annobin_encode_str.start.annobin_encode_str.endencode_str.annobin_encode_hk.isra.11.start.annobin_encode_hk.isra.11.endencode_hk.isra.11.annobin_encode_sv.start.annobin_encode_sv.endencode_svencode_hv.annobin_encode_hv.start.annobin_encode_hv.end.annobin_encode_json.start.annobin_encode_json.end.annobin_XS_JSON__XS_encode_json.start.annobin_XS_JSON__XS_encode_json.endXS_JSON__XS_encode_json.annobin_XS_JSON__XS_encode.start.annobin_XS_JSON__XS_encode.endXS_JSON__XS_encode.annobin_boot_JSON__XS.start.annobin_boot_JSON__XS.endcrtstuff.cderegister_tm_clones__do_global_dtors_auxcompleted.7303__do_global_dtors_aux_fini_array_entryframe_dummy__frame_dummy_init_array_entry__FRAME_END___fini__dso_handle_DYNAMIC__GNU_EH_FRAME_HDR__TMC_END___GLOBAL_OFFSET_TABLE__initPerl_sv_2iv_flags__snprintf_chk@@GLIBC_2.3.4Perl_hv_iterkeysvPerl_newRV_noincPerl_sv_2uv_flagsPerl_stack_grow_ITM_deregisterTMCloneTableqsort@@GLIBC_2.2.5Perl_sv_utf8_downgradePerl_sv_derived_fromPerl_av_lenPerl_pop_scope_edataPerl_newSVstrlen@@GLIBC_2.2.5__stack_chk_fail@@GLIBC_2.4Perl_sv_upgradePerl_sv_setiv_mgPL_thr_keyPerl_newSVnvPerl_sv_blessmemset@@GLIBC_2.2.5Perl_sv_chopPerl_sv_2pv_flagsPerl_xs_boot_epilogPerl_hv_iternext_flagsPerl_grok_numberPerl_get_cvboot_JSON__XSmemcmp@@GLIBC_2.2.5__gmon_start__Perl_newSVsvPerl_croak_xs_usagePerl_newSVpvn_flagsPerl_savetmpsPerl_sv_growPerl_sv_utf8_upgrade_flags_growmemcpy@@GLIBC_2.14Perl_gv_stashpvPerl_av_pushPerl_sv_cmp_flagsPerl_newSVpvpthread_getspecific@@GLIBC_2.2.5Perl_gv_fetchmethod_autoloadPerl_get_svPerl_croak_nocontextPerl_newXS_deffilePerl_pv_uni_displayPerl_gv_stashsvPerl_hv_iterinitPerl_newXS_flagsPerl_sv_2mortalPerl_mg_get__bss_startPerl_hv_commonPerl_newSVuvPerl_safesysreallocmemmove@@GLIBC_2.2.5Perl_xs_handshakegcvt@@GLIBC_2.2.5Perl_av_fetchPerl_utf8n_to_uvuniPerl_utf8_lengthpowPerl_free_tmpsPerl_markstack_growPerl_hv_common_key_lenPerl_newRVPerl_newSV_typePerl_block_gimmePL_hexdigitPerl_save_vptrPerl_call_svPerl_sv_setuv_mgPerl_sv_free2Perl_push_scope_ITM_registerTMCloneTablePerl_newSVivPerl_hv_itervalPerl_newSVpvn__cxa_finalize@@GLIBC_2.2.5Perl_sv_newmortalPerl_apply_attrs_stringPL_utf8skip__sprintf_chk@@GLIBC_2.3.4Perl_hv_placeholders_get.symtab.strtab.shstrtab.note.gnu.build-id.gnu.hash.dynsym.dynstr.gnu.version.gnu.version_r.rela.dyn.rela.plt.init.plt.sec.text.fini.rodata.eh_frame_hdr.eh_frame.note.gnu.property.init_array.fini_array.data.rel.ro.dynamic.got.bss.comment.gnu.build.attributes.debug_aranges.debug_info.debug_abbrev.debug_line.debug_str.debug_loc.debug_ranges88$.o``48 @@ HoUo88pdnB8xs~##U 0@@d `` 0 08 8@ @H HH H H 0-H`0 0, r;8bEF1MLvR0}G]y +h_7p]Д" ȮSvXS/Type.pm000044400000024035152350475520006367 0ustar00package Cpanel::JSON::XS::Type; =pod =head1 NAME Cpanel::JSON::XS::Type - Type support for JSON encode =head1 SYNOPSIS use Cpanel::JSON::XS; use Cpanel::JSON::XS::Type; encode_json([10, "10", 10.25], [JSON_TYPE_INT, JSON_TYPE_INT, JSON_TYPE_STRING]); # '[10,10,"10.25"]' encode_json([10, "10", 10.25], json_type_arrayof(JSON_TYPE_INT)); # '[10,10,10]' encode_json(1, JSON_TYPE_BOOL); # 'true' my $perl_struct = { key1 => 1, key2 => "2", key3 => 1 }; my $type_spec = { key1 => JSON_TYPE_STRING, key2 => JSON_TYPE_INT, key3 => JSON_TYPE_BOOL }; my $json_string = encode_json($perl_struct, $type_spec); # '{"key1":"1","key2":2,"key3":true}' my $perl_struct = { key1 => "value1", key2 => "value2", key3 => 0, key4 => 1, key5 => "string", key6 => "string2" }; my $type_spec = json_type_hashof(JSON_TYPE_STRING); my $json_string = encode_json($perl_struct, $type_spec); # '{"key1":"value1","key2":"value2","key3":"0","key4":"1","key5":"string","key6":"string2"}' my $perl_struct = { key1 => { key2 => [ 10, "10", 10.6 ] }, key3 => "10.5" }; my $type_spec = { key1 => json_type_anyof(JSON_TYPE_FLOAT, json_type_hashof(json_type_arrayof(JSON_TYPE_INT))), key3 => JSON_TYPE_FLOAT }; my $json_string = encode_json($perl_struct, $type_spec); # '{"key1":{"key2":[10,10,10]},"key3":10.5}' my $value = decode_json('false', 1, my $type); # $value is 0 and $type is JSON_TYPE_BOOL my $value = decode_json('0', 1, my $type); # $value is 0 and $type is JSON_TYPE_INT my $value = decode_json('"0"', 1, my $type); # $value is 0 and $type is JSON_TYPE_STRING my $json_string = '{"key1":{"key2":[10,"10",10.6]},"key3":"10.5"}'; my $perl_struct = decode_json($json_string, 0, my $type_spec); # $perl_struct is { key1 => { key2 => [ 10, 10, 10.6 ] }, key3 => 10.5 } # $type_spec is { key1 => { key2 => [ JSON_TYPE_INT, JSON_TYPE_STRING, JSON_TYPE_FLOAT ] }, key3 => JSON_TYPE_STRING } =head1 DESCRIPTION This module provides stable JSON type support for the L encoder which doesn't depend on any internal perl scalar flags or characteristics. Also it provides real JSON types for L decoder. In most cases perl structures passed to L come from other functions or from other modules and caller of Cpanel::JSON::XS module does not have control of internals or they are subject of change. So it is not easy to support enforcing types as described in the L section. For services based on JSON contents it is sometimes needed to correctly process and enforce JSON types. The function L takes optional third scalar parameter and fills it with specification of json types. The function L takes a perl structure as its input and optionally also a json type specification in the second parameter. If the specification is not provided (or is undef) internal perl scalar flags are used for the resulting JSON type. The internal flags can be changed by perl itself, but also by external modules. Which means that types in resulting JSON string aren't stable. Specially it does not work reliable for dual vars and scalars which were used in both numeric and string operations. See L. To enforce that specification is always provided use C. In this case when C is called without second argument (or is undef) then it croaks. It applies recursively for all sub-structures. =head2 JSON type specification for scalars: =over 4 =item JSON_TYPE_BOOL It enforces JSON boolean in resulting JSON, i.e. either C or C. For determining whether the scalar passed to the encoder is true, standard perl boolean logic is used. =item JSON_TYPE_INT It enforces JSON number without fraction part in the resulting JSON. Equivalent of perl function L is used for conversion. =item JSON_TYPE_FLOAT It enforces JSON number with fraction part in the resulting JSON. Equivalent of perl operation C<+0> is used for conversion. =item JSON_TYPE_STRING It enforces JSON string type in the resulting JSON. =item JSON_TYPE_NULL It represents JSON C value. Makes sense only when passing perl's C value. =back For each type, there also exists a type with the suffix C<_OR_NULL> which encodes perl's C into JSON C. Without type with suffix C<_OR_NULL> perl's C is converted to specific type according to above rules. =head2 JSON type specification for arrays: =over 4 =item [...] The array must contain the same number of elements as in the perl array passed for encoding. Each element of the array describes the JSON type which is enforced for the corresponding element of the perl array. =item json_type_arrayof This function takes a JSON type specification as its argument which is enforced for every element of the passed perl array. =back =head2 JSON type specification for hashes: =over 4 =item {...} Each hash value for corresponding key describes the JSON type specification for values of passed perl hash structure. Keys in hash which are not present in passed perl hash structure are simple ignored and not used. =item json_type_hashof This function takes a JSON type specification as its argument which is enforced for every value of passed perl hash structure. =back =head2 JSON type specification for alternatives: =over 4 =item json_type_anyof This function takes a list of JSON type alternative specifications (maximally one scalar, one array, and one hash) as its input and the JSON encoder chooses one that matches. =item json_type_null_or_anyof Like L|/json_type_anyof>, but scalar can be only perl's C. =back =head2 Recursive specifications =over 4 =item json_type_weaken This function can be used as an argument for L, L or L functions to create weak references suitable for complicated recursive structures. It depends on L module. See following example: my $struct = { type => JSON_TYPE_STRING, array => json_type_arrayof(JSON_TYPE_INT), }; $struct->{recursive} = json_type_anyof( json_type_weaken($struct), json_type_arrayof(JSON_TYPE_STRING), ); If you want to encode all perl scalars to JSON string types despite how complicated is input perl structure you can define JSON type specification for alternatives recursively. It could be defined as: my $type = json_type_anyof(); $type->[0] = JSON_TYPE_STRING_OR_NULL; $type->[1] = json_type_arrayof(json_type_weaken($type)); $type->[2] = json_type_hashof(json_type_weaken($type)); print encode_json([ 10, "10", { key => 10 } ], $type); # ["10","10",{"key":"10"}] An alternative solution for encoding all scalars to JSON strings is to use C method of L itself: my $json = Cpanel::JSON::XS->new->type_all_string; print $json->encode([ 10, "10", { key => 10 } ]); # ["10","10",{"key":"10"}] =back =head1 AUTHOR Pali Epali@cpan.orgE =head1 COPYRIGHT & LICENSE Copyright (c) 2017, GoodData Corporation. All rights reserved. This module is available under the same licences as perl, the Artistic license and the GPL. =cut use strict; use warnings; BEGIN { if (eval { require Scalar::Util }) { Scalar::Util->import('weaken'); } else { *weaken = sub($) { die 'Scalar::Util is required for weaken' }; } } # This exports needed XS constants to perl use Cpanel::JSON::XS (); use Exporter; our @ISA = qw(Exporter); our @EXPORT = our @EXPORT_OK = qw( json_type_arrayof json_type_hashof json_type_anyof json_type_null_or_anyof json_type_weaken JSON_TYPE_NULL JSON_TYPE_BOOL JSON_TYPE_INT JSON_TYPE_FLOAT JSON_TYPE_STRING JSON_TYPE_BOOL_OR_NULL JSON_TYPE_INT_OR_NULL JSON_TYPE_FLOAT_OR_NULL JSON_TYPE_STRING_OR_NULL JSON_TYPE_ARRAYOF_CLASS JSON_TYPE_HASHOF_CLASS JSON_TYPE_ANYOF_CLASS ); use constant JSON_TYPE_WEAKEN_CLASS => 'Cpanel::JSON::XS::Type::Weaken'; sub json_type_anyof { my ($scalar, $array, $hash); my ($scalar_weaken, $array_weaken, $hash_weaken); foreach (@_) { my $type = $_; my $ref = ref($_); my $weaken; if ($ref eq JSON_TYPE_WEAKEN_CLASS) { $type = ${$type}; $ref = ref($type); $weaken = 1; } if ($ref eq '') { die 'Only one scalar type can be specified in anyof' if defined $scalar; $scalar = $type; $scalar_weaken = $weaken; } elsif ($ref eq 'ARRAY' or $ref eq JSON_TYPE_ARRAYOF_CLASS) { die 'Only one array type can be specified in anyof' if defined $array; $array = $type; $array_weaken = $weaken; } elsif ($ref eq 'HASH' or $ref eq JSON_TYPE_HASHOF_CLASS) { die 'Only one hash type can be specified in anyof' if defined $hash; $hash = $type; $hash_weaken = $weaken; } else { die 'Only scalar, array or hash can be specified in anyof'; } } my $type = [$scalar, $array, $hash]; weaken $type->[0] if $scalar_weaken; weaken $type->[1] if $array_weaken; weaken $type->[2] if $hash_weaken; return bless $type, JSON_TYPE_ANYOF_CLASS; } sub json_type_null_or_anyof { foreach (@_) { die 'Scalar cannot be specified in null_or_anyof' if ref($_) eq ''; } return json_type_anyof(JSON_TYPE_CAN_BE_NULL, @_); } sub json_type_arrayof { die 'Exactly one type must be specified in arrayof' if scalar @_ != 1; my $type = $_[0]; if (ref($type) eq JSON_TYPE_WEAKEN_CLASS) { $type = ${$type}; weaken $type; } return bless \$type, JSON_TYPE_ARRAYOF_CLASS; } sub json_type_hashof { die 'Exactly one type must be specified in hashof' if scalar @_ != 1; my $type = $_[0]; if (ref($type) eq JSON_TYPE_WEAKEN_CLASS) { $type = ${$type}; weaken $type; } return bless \$type, JSON_TYPE_HASHOF_CLASS; } sub json_type_weaken { die 'Exactly one type must be specified in weaken' if scalar @_ != 1; die 'Scalar cannot be specfied in weaken' if ref($_[0]) eq ''; return bless \(my $type = $_[0]), JSON_TYPE_WEAKEN_CLASS; } 1; const_defined_in%3f-c.ri000064400000000423152353242040011107 0ustar00U:RDoc::AnyMethod[iI"const_defined_in?:EFI"JSON::const_defined_in?;TT: publico:RDoc::Markup::Document: @parts[: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below000[I"(modul, constant);T@ FI" JSON;FcRDoc::NormalModule00state-c.ri000064400000000626152353242040006444 0ustar00U:RDoc::Attr[iI" state:ETI"JSON::state;TI"RW;T: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"JReturns the JSON generator state class that is used by JSON. This is ;TI"Heither JSON::Ext::Generator::State or JSON::Pure::Generator::State.;T: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below0T@I" JSON;FcRDoc::NormalModule0ParserError/cdesc-ParserError.ri000064400000000764152353242040012702 0ustar00U:RDoc::NormalClass[iI"ParserError:ETI"JSON::ParserError;TI"JSON::JSONError;To:RDoc::Markup::Document: @parts[o;;[o:RDoc::Markup::Paragraph;[I"7This exception is raised if a parser error occurs.;T: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below0; 0; 0[[[[[I" class;T[[: public[[:protected[[: private[[I" instance;T[[; [[; [[;[[[U:RDoc::Context::Section[i0o;;[; 0; 0[@I" JSON;FcRDoc::NormalModulegenerator-c.ri000064400000000612152353242040007305 0ustar00U:RDoc::Attr[iI"generator:ETI"JSON::generator;TI"R;T: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"EReturns the JSON generator module that is used by JSON. This is ;TI":either JSON::Ext::Generator or JSON::Pure::Generator.;T: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below0T@I" JSON;FcRDoc::NormalModule0create_id-c.ri000064400000000634152353242040007242 0ustar00U:RDoc::Attr[iI"create_id:ETI"JSON::create_id;TI"RW;T: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"MThis is create identifier, which is used to decide if the _json_create_ ;TI"Chook of a class should be called. It defaults to 'json_class'.;T: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below0T@I" JSON;FcRDoc::NormalModule0UnparserError/cdesc-UnparserError.ri000064400000001007152353242040013577 0ustar00U:RDoc::NormalClass[iI"UnparserError:EFI"JSON::UnparserError;TI"JSON::JSONError;To:RDoc::Markup::Document: @parts[o;;[o:RDoc::Markup::Paragraph;[I"FThis exception is raised if a generator or unparser error occurs.;T: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below0; 0; 0[[[[[I" class;T[[: public[[:protected[[: private[[I" instance;T[[; [[; [[;[[[U:RDoc::Context::Section[i0o;;[; 0; 0[@I" JSON;FcRDoc::NormalModuledump-i.ri000064400000001763152353242040006302 0ustar00U:RDoc::AnyMethod[iI" dump:EFI"JSON#dump;TF: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"QDumps _obj_ as a JSON string, i.e. calls generate on the object and returns ;TI"the result.;To:RDoc::Markup::BlankLineo; ; [I"PIf anIO (an IO-like object or an object that responds to the write method) ;TI"4was given, the resulting JSON is written to it.;T@o; ; [I"QIf the number of nested arrays or objects exceeds _limit_, an ArgumentError ;TI"Hexception is raised. This argument is similar (but not exactly the ;TI"4same!) to the _limit_ argument in Marshal.dump.;T@o; ; [I"BThe default options for the generator can be changed via the ;TI"!dump_default_options method.;T@o; ; [I"MThis method is part of the implementation of the load/dump interface of ;TI"Marshal and YAML.;T: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below000[I"#(obj, anIO = nil, limit = nil);T@!FI" JSON;FcRDoc::NormalModule00%5b%5d-i.ri000064400000001205152353242040006175 0ustar00U:RDoc::AnyMethod[iI"[]:EFI" JSON#[];TF: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"OIf _object_ is string-like, parse the string and return the parsed result ;TI"Las a Ruby data structure. Otherwise generate a JSON text from the Ruby ;TI")data structure object and return it.;To:RDoc::Markup::BlankLineo; ; [I"OThe _opts_ argument is passed through to generate/parse respectively. See ;TI"0generate and parse for their documentation.;T: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below000[I"(object, opts = {});T@FI" JSON;FcRDoc::NormalModule00fast_generate-i.ri000064400000001202152353242040010130 0ustar00U:RDoc::AnyMethod[iI"fast_generate:EFI"JSON#fast_generate;TF: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"PGenerate a JSON document from the Ruby data structure _obj_ and return it. ;TI"AThis method disables the checks for circles in Ruby objects.;To:RDoc::Markup::BlankLineo; ; [I"P*WARNING*: Be careful not to pass any Ruby data structures with circles as ;TI"M_obj_ argument because this will cause JSON to go into an infinite loop.;T: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below000[I"(obj, opts = nil);T@FI" JSON;FcRDoc::NormalModule00load_default_options-c.ri000064400000000715152353242040011521 0ustar00U:RDoc::Attr[iI"load_default_options:ETI"JSON::load_default_options;TI"RW;T: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"9The global default options for the JSON.load method:;To:RDoc::Markup::Verbatim; [I":max_nesting: false ;TI":allow_nan: true ;TI":quirks_mode: true;T: @format0: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below0T@I" JSON;FcRDoc::NormalModule0recurse_proc-i.ri000064400000000600152353242040010015 0ustar00U:RDoc::AnyMethod[iI"recurse_proc:EFI"JSON#recurse_proc;TF: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"YRecursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_;T: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below000[I"(result, &proc);T@FI" JSON;FcRDoc::NormalModule00pretty_generate-i.ri000064400000001200152353242040010520 0ustar00U:RDoc::AnyMethod[iI"pretty_generate:EFI"JSON#pretty_generate;TF: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"PGenerate a JSON document from the Ruby data structure _obj_ and return it. ;TI"JThe returned document is a prettier form of the document returned by ;TI"#unparse.;To:RDoc::Markup::BlankLineo; ; [I"IThe _opts_ argument can be used to configure the generator. See the ;TI"5generate method for a more detailed explanation.;T: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below000[I"(obj, opts = nil);T@FI" JSON;FcRDoc::NormalModule00restore-i.ri000064400000000437152353242040007015 0ustar00U:RDoc::AnyMethod[iI" restore:EFI"JSON#restore;TF: privateo:RDoc::Markup::Document: @parts[: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below000[I"'(source, proc = nil, options = {});T@ FI" JSON;FcRDoc::NormalModule0[@FI" load;FJSONError/cdesc-JSONError.ri000064400000001016152353242040011523 0ustar00U:RDoc::NormalClass[iI"JSONError:ETI"JSON::JSONError;TI"StandardError;To:RDoc::Markup::Document: @parts[o;;[o:RDoc::Markup::Paragraph;[I"(The base exception for JSON errors.;T: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below0; 0; 0[[[[[I" class;T[[: public[[I" wrap;FI" ext/json/lib/json/common.rb;T[:protected[[: private[[I" instance;T[[; [[; [[;[[[U:RDoc::Context::Section[i0o;;[; 0; 0[@I" JSON;FcRDoc::NormalModuleJSONError/wrap-c.ri000064400000000402152353242040010050 0ustar00U:RDoc::AnyMethod[iI" wrap:EFI"JSON::JSONError::wrap;TT: publico:RDoc::Markup::Document: @parts[: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below000[I"(exception);T@ FI"JSONError;TcRDoc::NormalClass00dump_default_options-c.ri000064400000000715152353242040011547 0ustar00U:RDoc::Attr[iI"dump_default_options:ETI"JSON::dump_default_options;TI"RW;T: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"9The global default options for the JSON.dump method:;To:RDoc::Markup::Verbatim; [I":max_nesting: false ;TI":allow_nan: true ;TI":quirks_mode: true;T: @format0: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below0T@I" JSON;FcRDoc::NormalModule0CircularDatastructure/cdesc-CircularDatastructure.ri000064400000000644152353242040017021 0ustar00U:RDoc::NormalClass[iI"CircularDatastructure:ETI" JSON::CircularDatastructure;TI"JSON::NestingError;To:RDoc::Markup::Document: @parts[: @file0:0@omit_headings_from_table_of_contents_below0[[[[[I" class;T[[: public[[:protected[[: private[[I" instance;T[[; [[; [[; [[[U:RDoc::Context::Section[i0o;;[; 0; 0[I" ext/json/lib/json/common.rb;TI" JSON;FcRDoc::NormalModulegenerate-i.ri000064400000004070152353242040007121 0ustar00U:RDoc::AnyMethod[iI" generate:EFI"JSON#generate;TF: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"LGenerate a JSON document from the Ruby data structure _obj_ and return ;TI"+it. _state_ is * a JSON::State object,;To:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0; [o; ; [I"3or a Hash like object (responding to to_hash),;To;;0; [o; ; [I"8an object convertible into a hash by a to_h method,;To; ; [I"4that is used as or to configure a State object.;To:RDoc::Markup::BlankLineo; ; [I"QIt defaults to a state object, that creates the shortest possible JSON text ;TI"Min one line, checks for circular data structures and doesn't allow NaN, ;TI"Infinity, and -Infinity.;T@o; ; [I"0A _state_ hash can have the following keys:;To; ; ; ;[ o;;0; [o; ; [I"<*indent*: a string used to indent levels (default: ''),;To;;0; [o; ; [I"K*space*: a string that is put after, a : or , delimiter (default: ''),;To;;0; [o; ; [I"R*space_before*: a string that is put before a : pair delimiter (default: ''),;To;;0; [o; ; [I"Q*object_nl*: a string that is put at the end of a JSON object (default: ''),;To;;0; [o; ; [I"O*array_nl*: a string that is put at the end of a JSON array (default: ''),;To;;0; [o; ; [I"A*allow_nan*: true if NaN, Infinity, and -Infinity should be ;TI"Egenerated, otherwise an exception is thrown if these values are ;TI"1encountered. This options defaults to false.;To;;0; [o; ; [I"E*max_nesting*: The maximum depth of nesting allowed in the data ;TI"Kstructures from which JSON is to be generated. Disable depth checking ;TI"4with :max_nesting => false, it defaults to 100.;T@o; ; [I"OSee also the fast_generate for the fastest creation method with the least ;TI"Famount of sanity checks, and the pretty_generate method for some ;TI" defaults for pretty output.;T: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below000[I"(obj, opts = nil);T@UFI" JSON;FcRDoc::NormalModule00cdesc-JSON.ri000064400000007757152353242040006750 0ustar00U:RDoc::NormalModule[iI" JSON:EF@0o:RDoc::Markup::Document: @parts[ o;;[!S:RDoc::Markup::Heading: leveli: textI"&JavaScript Object Notation (JSON);To:RDoc::Markup::BlankLineo:RDoc::Markup::Paragraph;[I"FJSON is a lightweight data-interchange format. It is easy for us ;TI"Whumans to read and write. Plus, equally simple for machines to generate or parse. ;TI"RJSON is completely language agnostic, making it the ideal interchange format.;T@o; ;[I"3Built on two universally available structures:;To:RDoc::Markup::Verbatim;[I"1. A collection of name/value pairs. Often referred to as an _object_, hash table, record, struct, keyed list, or associative array. ;TI"^2. An ordered list of values. More commonly called an _array_, vector, sequence or list. ;T: @format0o; ;[I"3To read more about JSON visit: http://json.org;T@S; ; i; I"Parsing JSON;T@o; ;[I"PTo parse a JSON string received by another application or generated within ;TI"your existing application:;T@o;;[ I"require 'json' ;TI" ;TI"2my_hash = JSON.parse('{"hello": "goodbye"}') ;TI"(puts my_hash["hello"] => "goodbye" ;T;0o; ;[I"PNotice the extra quotes '' around the hash notation. Ruby expects ;TI"Pthe argument to be a string and can't convert objects like a hash or array.;T@o; ;[I"*Ruby converts your string into a hash;T@S; ; i; I"Generating JSON;T@o; ;[I"BCreating a JSON string for communication or serialization is ;TI"just as simple.;T@o;;[ I"require 'json' ;TI" ;TI"%my_hash = {:hello => "goodbye"} ;TI">puts JSON.generate(my_hash) => "{\"hello\":\"goodbye\"}" ;T;0o; ;[I"Or an alternative way:;T@o;;[I"require 'json' ;TI"Eputs {:hello => "goodbye"}.to_json => "{\"hello\":\"goodbye\"}" ;T;0o; ;[I"JJSON.generate only allows objects or arrays to be converted ;TI"Jto JSON syntax. to_json, however, accepts many Ruby classes ;TI" "1";T;0: @fileI"ext/json/lib/json.rb;T:0@omit_headings_from_table_of_contents_below0o;;[;I" ext/json/lib/json/common.rb;T;0o;;[;I"ext/json/lib/json/ext.rb;T;0o;;[;I"(ext/json/lib/json/generic_object.rb;T;0o;;[;I"!ext/json/lib/json/version.rb;T;0;0;0[ [ I"create_id;TI"RW;T: publicTI" ext/json/lib/json/common.rb;T[ I"dump_default_options;TI"RW;T;T@_[ I"generator;TI"R;T;T@_[ I"load_default_options;TI"RW;T;T@_[ I" parser;TI"R;T;T@_[ I" state;TI"RW;T;T@_[ U:RDoc::Constant[iI"NaN;FI"JSON::NaN;T00o;;[;@Q;0@Q@cRDoc::NormalModule0U;[iI" Infinity;FI"JSON::Infinity;T00o;;[;@Q;0@Q@@v0U;[iI"MinusInfinity;FI"JSON::MinusInfinity;T00o;;[;@Q;0@Q@@v0U;[iI"UnparserError;FI"JSON::UnparserError;T0I"JSON::GeneratorError;To;;[o; ;[I"FThis exception is raised if a generator or unparser error occurs.;T;@Q;0@Q@@v0U;[iI"JSON_LOADED;FI"JSON::JSON_LOADED;T00o;;[;@T;0@T@@v0U;[iI" VERSION;FI"JSON::VERSION;T00o;;[o; ;[I"JSON version;T;@Z;0@Z@@v0[[[I" class;T[[;[[I"const_defined_in?;F@_[I" iconv;F@_[I" restore;F@_[:protected[[: private[[I" instance;T[[;[[I"[];F@_[I" dump;F@_[I"fast_generate;F@_[I" generate;F@_[I" load;F@_[I" parse;F@_[I" parse!;F@_[I"pretty_generate;F@_[I"recurse_proc;F@_[;[[;[[@@_[[U:RDoc::Context::Section[i0o;;[;0;0[@NI"(ext/json/lib/json/add/bigdecimal.rb;TI"%ext/json/lib/json/add/complex.rb;TI""ext/json/lib/json/add/date.rb;TI"'ext/json/lib/json/add/date_time.rb;TI"'ext/json/lib/json/add/exception.rb;TI"%ext/json/lib/json/add/ostruct.rb;TI"#ext/json/lib/json/add/range.rb;TI"&ext/json/lib/json/add/rational.rb;TI"$ext/json/lib/json/add/regexp.rb;TI"$ext/json/lib/json/add/struct.rb;TI"$ext/json/lib/json/add/symbol.rb;TI""ext/json/lib/json/add/time.rb;T@Q@T@W@Z@ZcRDoc::TopLevelGenericObject/from_hash-i.ri000064400000000430152353242040011774 0ustar00U:RDoc::AnyMethod[iI"from_hash:EFI""JSON::GenericObject#from_hash;TF: publico:RDoc::Markup::Document: @parts[: @fileI"(ext/json/lib/json/generic_object.rb;T:0@omit_headings_from_table_of_contents_below000[I" (object);T@ FI"GenericObject;TcRDoc::NormalClass00GenericObject/dump-i.ri000064400000000422152353242040010774 0ustar00U:RDoc::AnyMethod[iI" dump:EFI"JSON::GenericObject#dump;TF: publico:RDoc::Markup::Document: @parts[: @fileI"(ext/json/lib/json/generic_object.rb;T:0@omit_headings_from_table_of_contents_below000[I"(obj, *args);T@ FI"GenericObject;TcRDoc::NormalClass00GenericObject/%5b%5d-i.ri000064400000000410152353242040010675 0ustar00U:RDoc::AnyMethod[iI"[]:EFI"JSON::GenericObject#[];TF: publico:RDoc::Markup::Document: @parts[: @fileI"(ext/json/lib/json/generic_object.rb;T:0@omit_headings_from_table_of_contents_below000[I" (name);T@ FI"GenericObject;TcRDoc::NormalClass00GenericObject/as_json-i.ri000064400000000417152353242040011467 0ustar00U:RDoc::AnyMethod[iI" as_json:EFI" JSON::GenericObject#as_json;TF: publico:RDoc::Markup::Document: @parts[: @fileI"(ext/json/lib/json/generic_object.rb;T:0@omit_headings_from_table_of_contents_below000[I"(*);T@ FI"GenericObject;TcRDoc::NormalClass00GenericObject/to_json-i.ri000064400000000420152353242040011500 0ustar00U:RDoc::AnyMethod[iI" to_json:EFI" JSON::GenericObject#to_json;TF: publico:RDoc::Markup::Document: @parts[: @fileI"(ext/json/lib/json/generic_object.rb;T:0@omit_headings_from_table_of_contents_below000[I" (*a);T@ FI"GenericObject;TcRDoc::NormalClass00GenericObject/to_hash-i.ri000064400000000416152353242040011457 0ustar00U:RDoc::AnyMethod[iI" to_hash:EFI" JSON::GenericObject#to_hash;TF: publico:RDoc::Markup::Document: @parts[: @fileI"(ext/json/lib/json/generic_object.rb;T:0@omit_headings_from_table_of_contents_below000[I"();T@ FI"GenericObject;TcRDoc::NormalClass00GenericObject/json_create-i.ri000064400000000432152353242040012324 0ustar00U:RDoc::AnyMethod[iI"json_create:EFI"$JSON::GenericObject#json_create;TF: publico:RDoc::Markup::Document: @parts[: @fileI"(ext/json/lib/json/generic_object.rb;T:0@omit_headings_from_table_of_contents_below000[I" (data);T@ FI"GenericObject;TcRDoc::NormalClass00GenericObject/%5b%5d%3d-i.ri000064400000000421152353242040011173 0ustar00U:RDoc::AnyMethod[iI"[]=:EFI"JSON::GenericObject#[]=;TF: publico:RDoc::Markup::Document: @parts[: @fileI"(ext/json/lib/json/generic_object.rb;T:0@omit_headings_from_table_of_contents_below000[I"(name, value);T@ FI"GenericObject;TcRDoc::NormalClass00GenericObject/%7c-i.ri000064400000000407152353242040010410 0ustar00U:RDoc::AnyMethod[iI"|:ETI"JSON::GenericObject#|;TF: publico:RDoc::Markup::Document: @parts[: @fileI"(ext/json/lib/json/generic_object.rb;T:0@omit_headings_from_table_of_contents_below000[I" (other);T@ FI"GenericObject;TcRDoc::NormalClass00GenericObject/cdesc-GenericObject.ri000064400000001256152353242040013371 0ustar00U:RDoc::NormalClass[iI"GenericObject:ETI"JSON::GenericObject;TI"OpenStruct;To:RDoc::Markup::Document: @parts[o;;[: @fileI"(ext/json/lib/json/generic_object.rb;T:0@omit_headings_from_table_of_contents_below0; 0; 0[[ I"json_creatable;TI"W;T: publicTI"(ext/json/lib/json/generic_object.rb;T[[[[I" class;T[[; [[:protected[[: private[[I" instance;T[[; [[I"[];F@[I"[]=;F@[I" as_json;F@[I" dump;F@[I"from_hash;F@[I"json_creatable?;F@[I"json_create;F@[I" load;F@[I" to_hash;F@[I" to_json;F@[I"|;T@[; [[; [[[U:RDoc::Context::Section[i0o;;[; 0; 0[@I" JSON;FcRDoc::NormalModuleGenericObject/load-i.ri000064400000000445152353242040010753 0ustar00U:RDoc::AnyMethod[iI" load:EFI"JSON::GenericObject#load;TF: publico:RDoc::Markup::Document: @parts[: @fileI"(ext/json/lib/json/generic_object.rb;T:0@omit_headings_from_table_of_contents_below000[I"$(source, proc = nil, opts = {});T@ FI"GenericObject;TcRDoc::NormalClass00GenericObject/json_creatable-c.ri000064400000000427152353242040013001 0ustar00U:RDoc::Attr[iI"json_creatable:ETI"(JSON::GenericObject::json_creatable;TI"W;T: publico:RDoc::Markup::Document: @parts[: @fileI"(ext/json/lib/json/generic_object.rb;T:0@omit_headings_from_table_of_contents_below0T@ I"JSON::GenericObject;TcRDoc::NormalClass0GenericObject/json_creatable%3f-i.ri000064400000000436152353242040013305 0ustar00U:RDoc::AnyMethod[iI"json_creatable?:EFI"(JSON::GenericObject#json_creatable?;TF: publico:RDoc::Markup::Document: @parts[: @fileI"(ext/json/lib/json/generic_object.rb;T:0@omit_headings_from_table_of_contents_below000[I"();T@ FI"GenericObject;TcRDoc::NormalClass00parser-c.ri000064400000000572152353242040006620 0ustar00U:RDoc::Attr[iI" parser:ETI"JSON::parser;TI"R;T: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"HReturns the JSON parser class that is used by JSON. This is either ;TI"-JSON::Ext::Parser or JSON::Pure::Parser.;T: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below0T@I" JSON;FcRDoc::NormalModule0GeneratorError/cdesc-GeneratorError.ri000064400000001011152353242040014050 0ustar00U:RDoc::NormalClass[iI"GeneratorError:ETI"JSON::GeneratorError;TI"JSON::JSONError;To:RDoc::Markup::Document: @parts[o;;[o:RDoc::Markup::Paragraph;[I"FThis exception is raised if a generator or unparser error occurs.;T: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below0; 0; 0[[[[[I" class;T[[: public[[:protected[[: private[[I" instance;T[[; [[; [[;[[[U:RDoc::Context::Section[i0o;;[; 0; 0[@I" JSON;FcRDoc::NormalModuleiconv-c.ri000064400000000515152353242040006437 0ustar00U:RDoc::AnyMethod[iI" iconv:EFI"JSON::iconv;TT: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"0Encodes string using Ruby's _String.encode_;T: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below000[I"(to, from, string);T@FI" JSON;FcRDoc::NormalModule00MissingUnicodeSupport/cdesc-MissingUnicodeSupport.ri000064400000001153152353242040017011 0ustar00U:RDoc::NormalClass[iI"MissingUnicodeSupport:ETI" JSON::MissingUnicodeSupport;TI"JSON::JSONError;To:RDoc::Markup::Document: @parts[o;;[o:RDoc::Markup::Paragraph;[I"PThis exception is raised if the required unicode support is missing on the ;TI"Hsystem. Usually this means that the iconv library is not installed.;T: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below0; 0; 0[[[[[I" class;T[[: public[[:protected[[: private[[I" instance;T[[; [[; [[;[[[U:RDoc::Context::Section[i0o;;[; 0; 0[@I" JSON;FcRDoc::NormalModuleload-i.ri000064400000002273152353242040006251 0ustar00U:RDoc::AnyMethod[iI" load:EFI"JSON#load;TF: publico:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [ I"QLoad a ruby data structure from a JSON _source_ and return it. A source can ;TI"Peither be a string-like object, an IO-like object, or an object responding ;TI"Pto the read method. If _proc_ was given, it will be called with any nested ;TI"PRuby object as an argument recursively in depth first order. To modify the ;TI"Edefault options pass in the optional _options_ argument as well.;To:RDoc::Markup::BlankLineo; ; [ I"MBEWARE: This method is meant to serialise data from trusted user input, ;TI"Plike from your own database server or clients under your control, it could ;TI"Mbe dangerous to allow untrusted users to pass JSON sources into it. The ;TI"Pdefault options for the parser can be changed via the load_default_options ;TI" method.;T@o; ; [I"MThis method is part of the implementation of the load/dump interface of ;TI"Marshal and YAML.;T: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below000[[I" restore;Fo;; [; @; 0I"'(source, proc = nil, options = {});T@FI" JSON;FcRDoc::NormalModule00Ext/cdesc-Ext.ri000064400000001000152353242040007446 0ustar00U:RDoc::NormalModule[iI"Ext:EFI"JSON::Ext;T0o:RDoc::Markup::Document: @parts[o;;[o:RDoc::Markup::Paragraph;[I"EThis module holds all the modules/classes that implement JSON's ;TI"#functionality as C extensions.;T: @fileI"ext/json/lib/json/ext.rb;T:0@omit_headings_from_table_of_contents_below0; 0; 0[[[[[I" class;T[[: public[[:protected[[: private[[I" instance;T[[; [[; [[;[[[U:RDoc::Context::Section[i0o;;[; 0; 0[@I" JSON;FcRDoc::NormalModulerestore-c.ri000064400000000437152353242040007007 0ustar00U:RDoc::AnyMethod[iI" restore:EFI"JSON::restore;TT: publico:RDoc::Markup::Document: @parts[: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below000[I"'(source, proc = nil, options = {});T@ FI" JSON;FcRDoc::NormalModule0[@FI" load;Fparse%21-i.ri000064400000002524152353242040006653 0ustar00U:RDoc::AnyMethod[iI" parse!:EFI"JSON#parse!;TF: publico:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"PParse the JSON document _source_ into a Ruby data structure and return it. ;TI"PThe bang version of the parse method defaults to the more dangerous values ;TI"Nfor the _opts_ hash, so be sure only to parse trusted _source_ documents.;To:RDoc::Markup::BlankLineo; ; [I"(_opts_ can have the following keys:;To:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0; [o; ; [ I"L*max_nesting*: The maximum depth of nesting allowed in the parsed data ;TI"Rstructures. Enable depth checking with :max_nesting => anInteger. The parse! ;TI"Mmethods defaults to not doing max depth checking: This can be dangerous ;TI",if someone wants to fill up your stack.;To;;0; [o; ; [I"H*allow_nan*: If set to true, allow NaN, Infinity, and -Infinity in ;TI"Kdefiance of RFC 4627 to be parsed by the Parser. This option defaults ;TI" to true.;To;;0; [o; ; [I"D*create_additions*: If set to false, the Parser doesn't create ;TI"Madditions even if a matching class and create_id was found. This option ;TI"defaults to true.;T: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below000[I"(source, opts = {});T@,FI" JSON;FcRDoc::NormalModule00NestingError/cdesc-NestingError.ri000064400000001033152353242040013216 0ustar00U:RDoc::NormalClass[iI"NestingError:ETI"JSON::NestingError;TI"JSON::ParserError;To:RDoc::Markup::Document: @parts[o;;[o:RDoc::Markup::Paragraph;[I"NThis exception is raised if the nesting of parsed data structures is too ;TI" deep.;T: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below0; 0; 0[[[[[I" class;T[[: public[[:protected[[: private[[I" instance;T[[; [[; [[;[[[U:RDoc::Context::Section[i0o;;[; 0; 0[@I" JSON;FcRDoc::NormalModuleparse-i.ri000064400000002563152353242040006446 0ustar00U:RDoc::AnyMethod[iI" parse:EFI"JSON#parse;TF: publico:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"OParse the JSON document _source_ into a Ruby data structure and return it.;To:RDoc::Markup::BlankLineo; ; [I"#_opts_ can have the following ;TI" keys:;To:RDoc::Markup::List: @type: BULLET: @items[ o:RDoc::Markup::ListItem: @label0; [o; ; [I"L*max_nesting*: The maximum depth of nesting allowed in the parsed data ;TI"Pstructures. Disable depth checking with :max_nesting => false. It defaults ;TI" to 100.;To;;0; [o; ; [I"G*allow_nan*: If set to true, allow NaN, Infinity and -Infinity in ;TI"Kdefiance of RFC 4627 to be parsed by the Parser. This option defaults ;TI"to false.;To;;0; [o; ; [I"F*symbolize_names*: If set to true, returns symbols for the names ;TI"J(keys) in a JSON object. Otherwise strings are returned. Strings are ;TI"the default.;To;;0; [o; ; [I"D*create_additions*: If set to false, the Parser doesn't create ;TI"Madditions even if a matching class and create_id was found. This option ;TI"defaults to true.;To;;0; [o; ; [I"%*object_class*: Defaults to Hash;To;;0; [o; ; [I"%*array_class*: Defaults to Array;T: @fileI" ext/json/lib/json/common.rb;T:0@omit_headings_from_table_of_contents_below000[I"(source, opts = {});T@;FI" JSON;FcRDoc::NormalModule00