{
    "content": [
        {
            "type": "text",
            "text": "# JSON (perldoc)\n\n## NAME\n\nJSON - JSON (JavaScript Object Notation) encoder/decoder\n\n## SYNOPSIS\n\nuse JSON; # imports encodejson, decodejson, tojson and fromjson.\n# simple and fast interfaces (expect/generate UTF-8)\n$utf8encodedjsontext = encodejson $perlhashorarrayref;\n$perlhashorarrayref  = decodejson $utf8encodedjsontext;\n# OO-interface\n$json = JSON->new->allownonref;\n$jsontext   = $json->encode( $perlscalar );\n$perlscalar = $json->decode( $jsontext );\n$prettyprinted = $json->pretty->encode( $perlscalar ); # pretty-printing\n\n## DESCRIPTION\n\nThis module is a thin wrapper for JSON::XS-compatible modules with a few additional features.\nAll the backend modules convert a Perl data structure to a JSON text and vice versa. This module\nuses JSON::XS by default, and when JSON::XS is not available, falls back on JSON::PP, which is\nin the Perl core since 5.14. If JSON::PP is not available either, this module then falls back on\nJSON::backportPP (which is actually JSON::PP in a different .pm file) bundled in the same\ndistribution as this module. You can also explicitly specify to use Cpanel::JSON::XS, a fork of\nJSON::XS by Reini Urban.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **VERSION**\n- **DESCRIPTION**\n- **CHOOSING BACKEND**\n- **USING OPTIONAL FEATURES** (3 subsections)\n- **FUNCTIONAL INTERFACE**\n- **COMMON OBJECT-ORIENTED INTERFACE**\n- **ADDITIONAL METHODS**\n- **INCREMENTAL PARSING**\n- **MAPPING**\n- **ENCODING/CODESET FLAG NOTES**\n- **BACKWARD INCOMPATIBILITY**\n- **BUGS**\n- **SEE ALSO**\n- **AUTHOR**\n- **CURRENT MAINTAINER**\n- **COPYRIGHT AND LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "JSON",
        "section": "",
        "mode": "perldoc",
        "summary": "JSON - JSON (JavaScript Object Notation) encoder/decoder",
        "synopsis": "use JSON; # imports encodejson, decodejson, tojson and fromjson.\n# simple and fast interfaces (expect/generate UTF-8)\n$utf8encodedjsontext = encodejson $perlhashorarrayref;\n$perlhashorarrayref  = decodejson $utf8encodedjsontext;\n# OO-interface\n$json = JSON->new->allownonref;\n$jsontext   = $json->encode( $perlscalar );\n$perlscalar = $json->decode( $jsontext );\n$prettyprinted = $json->pretty->encode( $perlscalar ); # pretty-printing",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 16,
                "subsections": []
            },
            {
                "name": "VERSION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 13,
                "subsections": []
            },
            {
                "name": "CHOOSING BACKEND",
                "lines": 21,
                "subsections": []
            },
            {
                "name": "USING OPTIONAL FEATURES",
                "lines": 3,
                "subsections": [
                    {
                        "name": "-support_by_pp",
                        "lines": 20
                    },
                    {
                        "name": "-convert_blessed_universally",
                        "lines": 27
                    },
                    {
                        "name": "-no_export",
                        "lines": 11
                    }
                ]
            },
            {
                "name": "FUNCTIONAL INTERFACE",
                "lines": 73,
                "subsections": []
            },
            {
                "name": "COMMON OBJECT-ORIENTED INTERFACE",
                "lines": 451,
                "subsections": []
            },
            {
                "name": "ADDITIONAL METHODS",
                "lines": 37,
                "subsections": []
            },
            {
                "name": "INCREMENTAL PARSING",
                "lines": 83,
                "subsections": []
            },
            {
                "name": "MAPPING",
                "lines": 242,
                "subsections": []
            },
            {
                "name": "ENCODING/CODESET FLAG NOTES",
                "lines": 79,
                "subsections": []
            },
            {
                "name": "BACKWARD INCOMPATIBILITY",
                "lines": 13,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 14,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "CURRENT MAINTAINER",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COPYRIGHT AND LICENSE",
                "lines": 7,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "JSON - JSON (JavaScript Object Notation) encoder/decoder\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use JSON; # imports encodejson, decodejson, tojson and fromjson.\n\n# simple and fast interfaces (expect/generate UTF-8)\n\n$utf8encodedjsontext = encodejson $perlhashorarrayref;\n$perlhashorarrayref  = decodejson $utf8encodedjsontext;\n\n# OO-interface\n\n$json = JSON->new->allownonref;\n\n$jsontext   = $json->encode( $perlscalar );\n$perlscalar = $json->decode( $jsontext );\n\n$prettyprinted = $json->pretty->encode( $perlscalar ); # pretty-printing\n",
                "subsections": []
            },
            "VERSION": {
                "content": "4.02\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This module is a thin wrapper for JSON::XS-compatible modules with a few additional features.\nAll the backend modules convert a Perl data structure to a JSON text and vice versa. This module\nuses JSON::XS by default, and when JSON::XS is not available, falls back on JSON::PP, which is\nin the Perl core since 5.14. If JSON::PP is not available either, this module then falls back on\nJSON::backportPP (which is actually JSON::PP in a different .pm file) bundled in the same\ndistribution as this module. You can also explicitly specify to use Cpanel::JSON::XS, a fork of\nJSON::XS by Reini Urban.\n\nAll these backend modules have slight incompatibilities between them, including extra features\nthat other modules don't support, but as long as you use only common features (most important\nones are described below), migration from backend to backend should be reasonably easy. For\ndetails, see each backend module you use.\n",
                "subsections": []
            },
            "CHOOSING BACKEND": {
                "content": "This module respects an environmental variable called \"PERLJSONBACKEND\" when it decides a\nbackend module to use. If this environmental variable is not set, it tries to load JSON::XS, and\nif JSON::XS is not available, it falls back on JSON::PP, and then JSON::backportPP if JSON::PP\nis not available either.\n\nIf you always don't want it to fall back on pure perl modules, set the variable like this\n(\"export\" may be \"setenv\", \"set\" and the likes, depending on your environment):\n\n> export PERLJSONBACKEND=JSON::XS\n\nIf you prefer Cpanel::JSON::XS to JSON::XS, then:\n\n> export PERLJSONBACKEND=Cpanel::JSON::XS,JSON::XS,JSON::PP\n\nYou may also want to set this variable at the top of your test files, in order not to be\nbothered with incompatibilities between backends (you need to wrap this in \"BEGIN\", and set\nbefore actually \"use\"-ing JSON module, as it decides its backend as soon as it's loaded):\n\nBEGIN { $ENV{PERLJSONBACKEND}='JSON::backportPP'; }\nuse JSON;\n",
                "subsections": []
            },
            "USING OPTIONAL FEATURES": {
                "content": "There are a few options you can set when you \"use\" this module. These historical options are\nonly kept for backward compatibility, and should not be used in a new application.\n",
                "subsections": [
                    {
                        "name": "-support_by_pp",
                        "content": "BEGIN { $ENV{PERLJSONBACKEND} = 'JSON::XS' }\n\nuse JSON -supportbypp;\n\nmy $json = JSON->new;\n# escapeslash is for JSON::PP only.\n$json->allownonref->escapeslash->encode(\"/\");\n\nWith this option, this module loads its pure perl backend along with its XS backend (if\navailable), and lets the XS backend to watch if you set a flag only JSON::PP supports. When\nyou do, the internal JSON::XS object is replaced with a newly created JSON::PP object with\nthe setting copied from the XS object, so that you can use JSON::PP flags (and its slower\n\"decode\"/\"encode\" methods) from then on. In other words, this is not something that allows\nyou to hook JSON::XS to change its behavior while keeping its speed. JSON::XS and JSON::PP\nobjects are quite different (JSON::XS object is a blessed scalar reference, while JSON::PP\nobject is a blessed hash reference), and can't share their internals.\n\nTo avoid needless overhead (by copying settings), you are advised not to use this option and\njust to use JSON::PP explicitly when you need JSON::PP features.\n"
                    },
                    {
                        "name": "-convert_blessed_universally",
                        "content": "use JSON -convertblesseduniversally;\n\nmy $json = JSON->new->allownonref->convertblessed;\nmy $object = bless {foo => 'bar'}, 'Foo';\n$json->encode($object); # => {\"foo\":\"bar\"}\n\nJSON::XS-compatible backend modules don't encode blessed objects by default (except for\ntheir boolean values, which are typically blessed JSON::PP::Boolean objects). If you need to\nencode a data structure that may contain objects, you usually need to look into the\nstructure and replace objects with alternative non-blessed values, or enable\n\"convertblessed\" and provide a \"TOJSON\" method for each object's (base) class that may be\nfound in the structure, in order to let the methods replace the objects with whatever scalar\nvalues the methods return.\n\nIf you need to serialise data structures that may contain arbitrary objects, it's probably\nbetter to use other serialisers (such as Sereal or Storable for example), but if you do want\nto use this module for that purpose, \"-convertblesseduniversally\" option may help, which\ntweaks \"encode\" method of the backend to install \"UNIVERSAL::TOJSON\" method (locally)\nbefore encoding, so that all the objects that don't have their own \"TOJSON\" method can fall\nback on the method in the \"UNIVERSAL\" namespace. Note that you still need to enable\n\"convertblessed\" flag to actually encode objects in a data structure, and\n\"UNIVERSAL::TOJSON\" method installed by this option only converts blessed hash/array\nreferences into their unblessed clone (including private keys/values that are not supposed\nto be exposed). Other blessed references will be converted into null.\n\nThis feature is experimental and may be removed in the future.\n"
                    },
                    {
                        "name": "-no_export",
                        "content": "When you don't want to import functional interfaces from a module, you usually supply \"()\"\nto its \"use\" statement.\n\nuse JSON (); # no functional interfaces\n\nIf you don't want to import functional interfaces, but you also want to use any of the above\noptions, add \"-noexport\" to the option list.\n\n# no functional interfaces, while JSON::PP support is enabled.\nuse JSON -supportbypp, -noexport;\n"
                    }
                ]
            },
            "FUNCTIONAL INTERFACE": {
                "content": "This section is taken from JSON::XS. \"encodejson\" and \"decodejson\" are exported by default.\n\nThis module also exports \"tojson\" and \"fromjson\" for backward compatibility. These are slower,\nand may expect/generate different stuff from what \"encodejson\" and \"decodejson\" do, depending\non their options. It's better just to use Object-Oriented interfaces than using these two\nfunctions.\n\nencodejson\n$jsontext = encodejson $perlscalar\n\nConverts the given Perl data structure to a UTF-8 encoded, binary string (that is, the string\ncontains octets only). Croaks on error.\n\nThis function call is functionally identical to:\n\n$jsontext = JSON->new->utf8->encode($perlscalar)\n\nExcept being faster.\n\ndecodejson\n$perlscalar = decodejson $jsontext\n\nThe opposite of \"encodejson\": expects an UTF-8 (binary) string and tries to parse that as an\nUTF-8 encoded JSON text, returning the resulting reference. Croaks on error.\n\nThis function call is functionally identical to:\n\n$perlscalar = JSON->new->utf8->decode($jsontext)\n\nExcept being faster.\n\ntojson\n$jsontext = tojson($perlscalar[, $optionalhashref])\n\nConverts the given Perl data structure to a Unicode string by default. Croaks on error.\n\nBasically, this function call is functionally identical to:\n\n$jsontext = JSON->new->encode($perlscalar)\n\nExcept being slower.\n\nYou can pass an optional hash reference to modify its behavior, but that may change what\n\"tojson\" expects/generates (see \"ENCODING/CODESET FLAG NOTES\" for details).\n\n$jsontext = tojson($perlscalar, {utf8 => 1, pretty => 1})\n# => JSON->new->utf8(1)->pretty(1)->encode($perlscalar)\n\nfromjson\n$perlscalar = fromjson($jsontext[, $optionalhashref])\n\nThe opposite of \"tojson\": expects a Unicode string and tries to parse it, returning the\nresulting reference. Croaks on error.\n\nBasically, this function call is functionally identical to:\n\n$perlscalar = JSON->new->decode($jsontext)\n\nYou can pass an optional hash reference to modify its behavior, but that may change what\n\"fromjson\" expects/generates (see \"ENCODING/CODESET FLAG NOTES\" for details).\n\n$perlscalar = fromjson($jsontext, {utf8 => 1})\n# => JSON->new->utf8(1)->decode($jsontext)\n\nJSON::isbool\n$isboolean = JSON::isbool($scalar)\n\nReturns true if the passed scalar represents either JSON::true or JSON::false, two constants\nthat act like 1 and 0 respectively and are also used to represent JSON \"true\" and \"false\" in\nPerl strings.\n\nSee MAPPING, below, for more information on how JSON values are mapped to Perl.\n",
                "subsections": []
            },
            "COMMON OBJECT-ORIENTED INTERFACE": {
                "content": "This section is also taken from JSON::XS.\n\nThe object oriented interface lets you configure your own encoding or decoding style, within the\nlimits of supported formats.\n\nnew\n$json = JSON->new\n\nCreates a new JSON::XS-compatible backend object that can be used to de/encode JSON strings. All\nboolean flags described below are by default *disabled* (with the exception of \"allownonref\",\nwhich defaults to *enabled* since version 4.0).\n\nThe mutators for flags all return the backend object again and thus calls can be chained:\n\nmy $json = JSON->new->utf8->spaceafter->encode({a => [1,2]})\n=> {\"a\": [1, 2]}\n\nascii\n$json = $json->ascii([$enable])\n\n$enabled = $json->getascii\n\nIf $enable is true (or missing), then the \"encode\" method will not generate characters outside\nthe code range 0..127 (which is ASCII). Any Unicode characters outside that range will be\nescaped using either a single \\uXXXX (BMP characters) or a double \\uHHHH\\uLLLLL escape sequence,\nas per RFC4627. The resulting encoded JSON text can be treated as a native Unicode string, an\nascii-encoded, latin1-encoded or UTF-8 encoded string, or any other superset of ASCII.\n\nIf $enable is false, then the \"encode\" method will not escape Unicode characters unless required\nby the JSON syntax or other flags. This results in a faster and more compact format.\n\nSee also the section *ENCODING/CODESET FLAG NOTES* later in this document.\n\nThe main use for this flag is to produce JSON texts that can be transmitted over a 7-bit\nchannel, as the encoded JSON texts will not contain any 8 bit characters.\n\nJSON->new->ascii(1)->encode([chr 0x10401])\n=> [\"\\ud801\\udc01\"]\n\nlatin1\n$json = $json->latin1([$enable])\n\n$enabled = $json->getlatin1\n\nIf $enable is true (or missing), then the \"encode\" method will encode the resulting JSON text as\nlatin1 (or iso-8859-1), escaping any characters outside the code range 0..255. The resulting\nstring can be treated as a latin1-encoded JSON text or a native Unicode string. The \"decode\"\nmethod will not be affected in any way by this flag, as \"decode\" by default expects Unicode,\nwhich is a strict superset of latin1.\n\nIf $enable is false, then the \"encode\" method will not escape Unicode characters unless required\nby the JSON syntax or other flags.\n\nSee also the section *ENCODING/CODESET FLAG NOTES* later in this document.\n\nThe main use for this flag is efficiently encoding binary data as JSON text, as most octets will\nnot be escaped, resulting in a smaller encoded size. The disadvantage is that the resulting JSON\ntext is encoded in latin1 (and must correctly be treated as such when storing and transferring),\na rare encoding for JSON. It is therefore most useful when you want to store data structures\nknown to contain binary data efficiently in files or databases, not when talking to other JSON\nencoders/decoders.\n\nJSON->new->latin1->encode ([\"\\x{89}\\x{abc}\"]\n=> [\"\\x{89}\\\\u0abc\"]    # (perl syntax, U+abc escaped, U+89 not)\n\nutf8\n$json = $json->utf8([$enable])\n\n$enabled = $json->getutf8\n\nIf $enable is true (or missing), then the \"encode\" method will encode the JSON result into\nUTF-8, as required by many protocols, while the \"decode\" method expects to be handled an\nUTF-8-encoded string. Please note that UTF-8-encoded strings do not contain any characters\noutside the range 0..255, they are thus useful for bytewise/binary I/O. In future versions,\nenabling this option might enable autodetection of the UTF-16 and UTF-32 encoding families, as\ndescribed in RFC4627.\n\nIf $enable is false, then the \"encode\" method will return the JSON string as a (non-encoded)\nUnicode string, while \"decode\" expects thus a Unicode string. Any decoding or encoding (e.g. to\nUTF-8 or UTF-16) needs to be done yourself, e.g. using the Encode module.\n\nSee also the section *ENCODING/CODESET FLAG NOTES* later in this document.\n\nExample, output UTF-16BE-encoded JSON:\n\nuse Encode;\n$jsontext = encode \"UTF-16BE\", JSON->new->encode ($object);\n\nExample, decode UTF-32LE-encoded JSON:\n\nuse Encode;\n$object = JSON->new->decode (decode \"UTF-32LE\", $jsontext);\n\npretty\n$json = $json->pretty([$enable])\n\nThis enables (or disables) all of the \"indent\", \"spacebefore\" and \"spaceafter\" (and in the\nfuture possibly more) flags in one call to generate the most readable (or most compact) form\npossible.\n\nindent\n$json = $json->indent([$enable])\n\n$enabled = $json->getindent\n\nIf $enable is true (or missing), then the \"encode\" method will use a multiline format as output,\nputting every array member or object/hash key-value pair into its own line, indenting them\nproperly.\n\nIf $enable is false, no newlines or indenting will be produced, and the resulting JSON text is\nguaranteed not to contain any \"newlines\".\n\nThis setting has no effect when decoding JSON texts.\n\nspacebefore\n$json = $json->spacebefore([$enable])\n\n$enabled = $json->getspacebefore\n\nIf $enable is true (or missing), then the \"encode\" method will add an extra optional space\nbefore the \":\" separating keys from values in JSON objects.\n\nIf $enable is false, then the \"encode\" method will not add any extra space at those places.\n\nThis setting has no effect when decoding JSON texts. You will also most likely combine this\nsetting with \"spaceafter\".\n\nExample, spacebefore enabled, spaceafter and indent disabled:\n\n{\"key\" :\"value\"}\n\nspaceafter\n$json = $json->spaceafter([$enable])\n\n$enabled = $json->getspaceafter\n\nIf $enable is true (or missing), then the \"encode\" method will add an extra optional space after\nthe \":\" separating keys from values in JSON objects and extra whitespace after the \",\"\nseparating key-value pairs and array members.\n\nIf $enable is false, then the \"encode\" method will not add any extra space at those places.\n\nThis setting has no effect when decoding JSON texts.\n\nExample, spacebefore and indent disabled, spaceafter enabled:\n\n{\"key\": \"value\"}\n\nrelaxed\n$json = $json->relaxed([$enable])\n\n$enabled = $json->getrelaxed\n\nIf $enable is true (or missing), then \"decode\" will accept some extensions to normal JSON syntax\n(see below). \"encode\" will not be affected in any way. *Be aware that this option makes you\naccept invalid JSON texts as if they were valid!*. I suggest only to use this option to parse\napplication-specific files written by humans (configuration files, resource files etc.)\n\nIf $enable is false (the default), then \"decode\" will only accept valid JSON texts.\n\nCurrently accepted extensions are:\n\n*   list items can have an end-comma\n\nJSON *separates* array elements and key-value pairs with commas. This can be annoying if you\nwrite JSON texts manually and want to be able to quickly append elements, so this extension\naccepts comma at the end of such items not just between them:\n\n[\n1,\n2, <- this comma not normally allowed\n]\n{\n\"k1\": \"v1\",\n\"k2\": \"v2\", <- this comma not normally allowed\n}\n\n*   shell-style '#'-comments\n\nWhenever JSON allows whitespace, shell-style comments are additionally allowed. They are\nterminated by the first carriage-return or line-feed character, after which more white-space\nand comments are allowed.\n\n[\n1, # this comment not allowed in JSON\n# neither this one...\n]\n\ncanonical\n$json = $json->canonical([$enable])\n\n$enabled = $json->getcanonical\n\nIf $enable is true (or missing), then the \"encode\" method will output JSON objects by sorting\ntheir keys. This is adding a comparatively high overhead.\n\nIf $enable is false, then the \"encode\" method will output key-value pairs in the order Perl\nstores them (which will likely change between runs of the same script, and can change even\nwithin the same run from 5.18 onwards).\n\nThis option is useful if you want the same data structure to be encoded as the same JSON text\n(given the same overall settings). If it is disabled, the same hash might be encoded differently\neven if contains the same data, as key-value pairs have no inherent ordering in Perl.\n\nThis setting has no effect when decoding JSON texts.\n\nThis setting has currently no effect on tied hashes.\n\nallownonref\n$json = $json->allownonref([$enable])\n\n$enabled = $json->getallownonref\n\nUnlike other boolean options, this option is enabled by default beginning with version 4.0.\n\nIf $enable is true (or missing), then the \"encode\" method can convert a non-reference into its\ncorresponding string, number or null JSON value, which is an extension to RFC4627. Likewise,\n\"decode\" will accept those JSON values instead of croaking.\n\nIf $enable is false, then the \"encode\" method will croak if it isn't passed an arrayref or\nhashref, as JSON texts must either be an object or array. Likewise, \"decode\" will croak if given\nsomething that is not a JSON object or array.\n\nExample, encode a Perl scalar as JSON value with enabled \"allownonref\", resulting in an invalid\nJSON text:\n\nJSON->new->allownonref->encode (\"Hello, World!\")\n=> \"Hello, World!\"\n\nallowunknown\n$json = $json->allowunknown ([$enable])\n\n$enabled = $json->getallowunknown\n\nIf $enable is true (or missing), then \"encode\" will *not* throw an exception when it encounters\nvalues it cannot represent in JSON (for example, filehandles) but instead will encode a JSON\n\"null\" value. Note that blessed objects are not included here and are handled separately by\nc<allowblessed>.\n\nIf $enable is false (the default), then \"encode\" will throw an exception when it encounters\nanything it cannot encode as JSON.\n\nThis option does not affect \"decode\" in any way, and it is recommended to leave it off unless\nyou know your communications partner.\n\nallowblessed\n$json = $json->allowblessed([$enable])\n\n$enabled = $json->getallowblessed\n\nSee \"OBJECT SERIALISATION\" for details.\n\nIf $enable is true (or missing), then the \"encode\" method will not barf when it encounters a\nblessed reference that it cannot convert otherwise. Instead, a JSON \"null\" value is encoded\ninstead of the object.\n\nIf $enable is false (the default), then \"encode\" will throw an exception when it encounters a\nblessed object that it cannot convert otherwise.\n\nThis setting has no effect on \"decode\".\n\nconvertblessed\n$json = $json->convertblessed([$enable])\n\n$enabled = $json->getconvertblessed\n\nSee \"OBJECT SERIALISATION\" for details.\n\nIf $enable is true (or missing), then \"encode\", upon encountering a blessed object, will check\nfor the availability of the \"TOJSON\" method on the object's class. If found, it will be called\nin scalar context and the resulting scalar will be encoded instead of the object.\n\nThe \"TOJSON\" method may safely call die if it wants. If \"TOJSON\" returns other blessed\nobjects, those will be handled in the same way. \"TOJSON\" must take care of not causing an\nendless recursion cycle (== crash) in this case. The name of \"TOJSON\" was chosen because other\nmethods called by the Perl core (== not by the user of the object) are usually in upper case\nletters and to avoid collisions with any \"tojson\" function or method.\n\nIf $enable is false (the default), then \"encode\" will not consider this type of conversion.\n\nThis setting has no effect on \"decode\".\n\nallowtags (since version 3.0)\n$json = $json->allowtags([$enable])\n\n$enabled = $json->getallowtags\n\nSee \"OBJECT SERIALISATION\" for details.\n\nIf $enable is true (or missing), then \"encode\", upon encountering a blessed object, will check\nfor the availability of the \"FREEZE\" method on the object's class. If found, it will be used to\nserialise the object into a nonstandard tagged JSON value (that JSON decoders cannot decode).\n\nIt also causes \"decode\" to parse such tagged JSON values and deserialise them via a call to the\n\"THAW\" method.\n\nIf $enable is false (the default), then \"encode\" will not consider this type of conversion, and\ntagged JSON values will cause a parse error in \"decode\", as if tags were not part of the\ngrammar.\n\nbooleanvalues (since version 4.0)\n$json->booleanvalues([$false, $true])\n\n($false,  $true) = $json->getbooleanvalues\n\nBy default, JSON booleans will be decoded as overloaded $JSON::false and $JSON::true objects.\n\nWith this method you can specify your own boolean values for decoding - on decode, JSON \"false\"\nwill be decoded as a copy of $false, and JSON \"true\" will be decoded as $true (\"copy\" here is\nthe same thing as assigning a value to another variable, i.e. \"$copy = $false\").\n\nThis is useful when you want to pass a decoded data structure directly to other serialisers like\nYAML, Data::MessagePack and so on.\n\nNote that this works only when you \"decode\". You can set incompatible boolean objects (like\nboolean), but when you \"encode\" a data structure with such boolean objects, you still need to\nenable \"convertblessed\" (and add a \"TOJSON\" method if necessary).\n\nCalling this method without any arguments will reset the booleans to their default values.\n\n\"getbooleanvalues\" will return both $false and $true values, or the empty list when they are\nset to the default.\n\nfilterjsonobject\n$json = $json->filterjsonobject([$coderef])\n\nWhen $coderef is specified, it will be called from \"decode\" each time it decodes a JSON object.\nThe only argument is a reference to the newly-created hash. If the code references returns a\nsingle scalar (which need not be a reference), this value (or rather a copy of it) is inserted\ninto the deserialised data structure. If it returns an empty list (NOTE: *not* \"undef\", which is\na valid scalar), the original deserialised hash will be inserted. This setting can slow down\ndecoding considerably.\n\nWhen $coderef is omitted or undefined, any existing callback will be removed and \"decode\" will\nnot change the deserialised hash in any way.\n\nExample, convert all JSON objects into the integer 5:\n\nmy $js = JSON->new->filterjsonobject(sub { 5 });\n# returns [5]\n$js->decode('[{}]');\n# returns 5\n$js->decode('{\"a\":1, \"b\":2}');\n\nfilterjsonsinglekeyobject\n$json = $json->filterjsonsinglekeyobject($key [=> $coderef])\n\nWorks remotely similar to \"filterjsonobject\", but is only called for JSON objects having a\nsingle key named $key.\n\nThis $coderef is called before the one specified via \"filterjsonobject\", if any. It gets\npassed the single value in the JSON object. If it returns a single value, it will be inserted\ninto the data structure. If it returns nothing (not even \"undef\" but the empty list), the\ncallback from \"filterjsonobject\" will be called next, as if no single-key callback were\nspecified.\n\nIf $coderef is omitted or undefined, the corresponding callback will be disabled. There can only\never be one callback for a given key.\n\nAs this callback gets called less often then the \"filterjsonobject\" one, decoding speed will\nnot usually suffer as much. Therefore, single-key objects make excellent targets to serialise\nPerl objects into, especially as single-key JSON objects are as close to the type-tagged value\nconcept as JSON gets (it's basically an ID/VALUE tuple). Of course, JSON does not support this\nin any way, so you need to make sure your data never looks like a serialised Perl hash.\n\nTypical names for the single object key are \"classwhatever\", or\n\"$dollarsarerarelyused$\" or \"}uglybraceplacement\", or even things like\n\"classmd5sum(classname)\", to reduce the risk of clashing with real hashes.\n\nExample, decode JSON objects of the form \"{ \"widget\" => <id> }\" into the corresponding\n$WIDGET{<id>} object:\n\n# return whatever is in $WIDGET{5}:\nJSON\n->new\n->filterjsonsinglekeyobject (widget => sub {\n$WIDGET{ $[0] }\n})\n->decode ('{\"widget\": 5')\n\n# this can be used with a TOJSON method in some \"widget\" class\n# for serialisation to json:\nsub WidgetBase::TOJSON {\nmy ($self) = @;\n\nunless ($self->{id}) {\n$self->{id} = ..get..some..id..;\n$WIDGET{$self->{id}} = $self;\n}\n\n{ widget => $self->{id} }\n}\n\nmaxdepth\n$json = $json->maxdepth([$maximumnestingdepth])\n\n$maxdepth = $json->getmaxdepth\n\nSets the maximum nesting level (default 512) accepted while encoding or decoding. If a higher\nnesting level is detected in JSON text or a Perl data structure, then the encoder and decoder\nwill stop and croak at that point.\n\nNesting level is defined by number of hash- or arrayrefs that the encoder needs to traverse to\nreach a given point or the number of \"{\" or \"[\" characters without their matching closing\nparenthesis crossed to reach a given character in a string.\n\nSetting the maximum depth to one disallows any nesting, so that ensures that the object is only\na single hash/object or array.\n\nIf no argument is given, the highest possible setting will be used, which is rarely useful.\n\nSee \"SECURITY CONSIDERATIONS\" in JSON::XS for more info on why this is useful.\n\nmaxsize\n$json = $json->maxsize([$maximumstringsize])\n\n$maxsize = $json->getmaxsize\n\nSet the maximum length a JSON text may have (in bytes) where decoding is being attempted. The\ndefault is 0, meaning no limit. When \"decode\" is called on a string that is longer then this\nmany bytes, it will not attempt to decode the string but throw an exception. This setting has no\neffect on \"encode\" (yet).\n\nIf no argument is given, the limit check will be deactivated (same as when 0 is specified).\n\nSee \"SECURITY CONSIDERATIONS\" in JSON::XS for more info on why this is useful.\n\nencode\n$jsontext = $json->encode($perlscalar)\n\nConverts the given Perl value or data structure to its JSON representation. Croaks on error.\n\ndecode\n$perlscalar = $json->decode($jsontext)\n\nThe opposite of \"encode\": expects a JSON text and tries to parse it, returning the resulting\nsimple scalar or reference. Croaks on error.\n\ndecodeprefix\n($perlscalar, $characters) = $json->decodeprefix($jsontext)\n\nThis works like the \"decode\" method, but instead of raising an exception when there is trailing\ngarbage after the first JSON object, it will silently stop parsing there and return the number\nof characters consumed so far.\n\nThis is useful if your JSON texts are not delimited by an outer protocol and you need to know\nwhere the JSON text ends.\n\nJSON->new->decodeprefix (\"[1] the tail\")\n=> ([1], 3)\n",
                "subsections": []
            },
            "ADDITIONAL METHODS": {
                "content": "The following methods are for this module only.\n\nbackend\n$backend = $json->backend\n\nSince 2.92, \"backend\" method returns an abstract backend module used currently, which should be\nJSON::Backend::XS (which inherits JSON::XS or Cpanel::JSON::XS), or JSON::Backend::PP (which\ninherits JSON::PP), not to monkey-patch the actual backend module globally.\n\nIf you need to know what is used actually, use \"isa\", instead of string comparison.\n\nisxs\n$boolean = $json->isxs\n\nReturns true if the backend inherits JSON::XS or Cpanel::JSON::XS.\n\nispp\n$boolean = $json->ispp\n\nReturns true if the backend inherits JSON::PP.\n\nproperty\n$settings = $json->property()\n\nReturns a reference to a hash that holds all the common flag settings.\n\n$json = $json->property('utf8' => 1)\n$value = $json->property('utf8') # 1\n\nYou can use this to get/set a value of a particular flag.\n\nboolean\n$booleanobject = JSON->boolean($scalar)\n\nReturns $JSON::true if $scalar contains a true value, $JSON::false otherwise. You can use this\nas a full-qualified function (\"JSON::boolean($scalar)\").\n",
                "subsections": []
            },
            "INCREMENTAL PARSING": {
                "content": "This section is also taken from JSON::XS.\n\nIn some cases, there is the need for incremental parsing of JSON texts. While this module always\nhas to keep both JSON text and resulting Perl data structure in memory at one time, it does\nallow you to parse a JSON stream incrementally. It does so by accumulating text until it has a\nfull JSON object, which it then can decode. This process is similar to using \"decodeprefix\" to\nsee if a full JSON object is available, but is much more efficient (and can be implemented with\na minimum of method calls).\n\nThis module will only attempt to parse the JSON text once it is sure it has enough text to get a\ndecisive result, using a very simple but truly incremental parser. This means that it sometimes\nwon't stop as early as the full parser, for example, it doesn't detect mismatched parentheses.\nThe only thing it guarantees is that it starts decoding as soon as a syntactically valid JSON\ntext has been seen. This means you need to set resource limits (e.g. \"maxsize\") to ensure the\nparser will stop parsing in the presence if syntax errors.\n\nThe following methods implement this incremental parser.\n\nincrparse\n$json->incrparse( [$string] ) # void context\n\n$objorundef = $json->incrparse( [$string] ) # scalar context\n\n@objorempty = $json->incrparse( [$string] ) # list context\n\nThis is the central parsing function. It can both append new text and extract objects from the\nstream accumulated so far (both of these functions are optional).\n\nIf $string is given, then this string is appended to the already existing JSON fragment stored\nin the $json object.\n\nAfter that, if the function is called in void context, it will simply return without doing\nanything further. This can be used to add more text in as many chunks as you want.\n\nIf the method is called in scalar context, then it will try to extract exactly *one* JSON\nobject. If that is successful, it will return this object, otherwise it will return \"undef\". If\nthere is a parse error, this method will croak just as \"decode\" would do (one can then use\n\"incrskip\" to skip the erroneous part). This is the most common way of using the method.\n\nAnd finally, in list context, it will try to extract as many objects from the stream as it can\nfind and return them, or the empty list otherwise. For this to work, there must be no separators\n(other than whitespace) between the JSON objects or arrays, instead they must be concatenated\nback-to-back. If an error occurs, an exception will be raised as in the scalar context case.\nNote that in this case, any previously-parsed JSON texts will be lost.\n\nExample: Parse some JSON arrays/objects in a given string and return them.\n\nmy @objs = JSON->new->incrparse (\"[5][7][1,2]\");\n\nincrtext\n$lvaluestring = $json->incrtext\n\nThis method returns the currently stored JSON fragment as an lvalue, that is, you can manipulate\nit. This *only* works when a preceding call to \"incrparse\" in *scalar context* successfully\nreturned an object. Under all other circumstances you must not call this function (I mean it.\nalthough in simple tests it might actually work, it *will* fail under real world conditions). As\na special exception, you can also call this method before having parsed anything.\n\nThat means you can only use this function to look at or manipulate text before or after complete\nJSON objects, not while the parser is in the middle of parsing a JSON object.\n\nThis function is useful in two cases: a) finding the trailing text after a JSON object or b)\nparsing multiple JSON objects separated by non-JSON text (such as commas).\n\nincrskip\n$json->incrskip\n\nThis will reset the state of the incremental parser and will remove the parsed text from the\ninput buffer so far. This is useful after \"incrparse\" died, in which case the input buffer and\nincremental parser state is left unchanged, to skip the text parsed so far and to reset the\nparse state.\n\nThe difference to \"incrreset\" is that only text until the parse error occurred is removed.\n\nincrreset\n$json->incrreset\n\nThis completely resets the incremental parser, that is, after this call, it will be as if the\nparser had never parsed anything.\n\nThis is useful if you want to repeatedly parse JSON objects and want to ignore any trailing\ndata, which means you have to reset the parser after each successful decode.\n",
                "subsections": []
            },
            "MAPPING": {
                "content": "Most of this section is also taken from JSON::XS.\n\nThis section describes how the backend modules map Perl values to JSON values and vice versa.\nThese mappings are designed to \"do the right thing\" in most circumstances automatically,\npreserving round-tripping characteristics (what you put in comes out as something equivalent).\n\nFor the more enlightened: note that in the following descriptions, lowercase *perl* refers to\nthe Perl interpreter, while uppercase *Perl* refers to the abstract Perl language itself.\n\nJSON -> PERL\nobject\nA JSON object becomes a reference to a hash in Perl. No ordering of object keys is preserved\n(JSON does not preserver object key ordering itself).\n\narray\nA JSON array becomes a reference to an array in Perl.\n\nstring\nA JSON string becomes a string scalar in Perl - Unicode codepoints in JSON are represented\nby the same codepoints in the Perl string, so no manual decoding is necessary.\n\nnumber\nA JSON number becomes either an integer, numeric (floating point) or string scalar in perl,\ndepending on its range and any fractional parts. On the Perl level, there is no difference\nbetween those as Perl handles all the conversion details, but an integer may take slightly\nless memory and might represent more values exactly than floating point numbers.\n\nIf the number consists of digits only, this module will try to represent it as an integer\nvalue. If that fails, it will try to represent it as a numeric (floating point) value if\nthat is possible without loss of precision. Otherwise it will preserve the number as a\nstring value (in which case you lose roundtripping ability, as the JSON number will be\nre-encoded to a JSON string).\n\nNumbers containing a fractional or exponential part will always be represented as numeric\n(floating point) values, possibly at a loss of precision (in which case you might lose\nperfect roundtripping ability, but the JSON number will still be re-encoded as a JSON\nnumber).\n\nNote that precision is not accuracy - binary floating point values cannot represent most\ndecimal fractions exactly, and when converting from and to floating point, this module only\nguarantees precision up to but not including the least significant bit.\n\ntrue, false\nThese JSON atoms become \"JSON::true\" and \"JSON::false\", respectively. They are overloaded to\nact almost exactly like the numbers 1 and 0. You can check whether a scalar is a JSON\nboolean by using the \"JSON::isbool\" function.\n\nnull\nA JSON null atom becomes \"undef\" in Perl.\n\nshell-style comments (\"# *text*\")\nAs a nonstandard extension to the JSON syntax that is enabled by the \"relaxed\" setting,\nshell-style comments are allowed. They can start anywhere outside strings and go till the\nend of the line.\n\ntagged values (\"(*tag*)*value*\").\nAnother nonstandard extension to the JSON syntax, enabled with the \"allowtags\" setting, are\ntagged values. In this implementation, the *tag* must be a perl package/class name encoded\nas a JSON string, and the *value* must be a JSON array encoding optional constructor\narguments.\n\nSee \"OBJECT SERIALISATION\", below, for details.\n\nPERL -> JSON\nThe mapping from Perl to JSON is slightly more difficult, as Perl is a truly typeless language,\nso we can only guess which JSON type is meant by a Perl value.\n\nhash references\nPerl hash references become JSON objects. As there is no inherent ordering in hash keys (or\nJSON objects), they will usually be encoded in a pseudo-random order. This module can\noptionally sort the hash keys (determined by the *canonical* flag), so the same data\nstructure will serialise to the same JSON text (given same settings and version of the same\nbackend), but this incurs a runtime overhead and is only rarely useful, e.g. when you want\nto compare some JSON text against another for equality.\n\narray references\nPerl array references become JSON arrays.\n\nother references\nOther unblessed references are generally not allowed and will cause an exception to be\nthrown, except for references to the integers 0 and 1, which get turned into \"false\" and\n\"true\" atoms in JSON. You can also use \"JSON::false\" and \"JSON::true\" to improve\nreadability.\n\nencodejson [\\0,JSON::true]      # yields [false,true]\n\nJSON::true, JSON::false, JSON::null\nThese special values become JSON true and JSON false values, respectively. You can also use\n\"\\1\" and \"\\0\" directly if you want.\n\nblessed objects\nBlessed objects are not directly representable in JSON, but \"JSON::XS\" allows various ways\nof handling objects. See \"OBJECT SERIALISATION\", below, for details.\n\nsimple scalars\nSimple Perl scalars (any scalar that is not a reference) are the most difficult objects to\nencode: this module will encode undefined scalars as JSON \"null\" values, scalars that have\nlast been used in a string context before encoding as JSON strings, and anything else as\nnumber value:\n\n# dump as number\nencodejson [2]                      # yields [2]\nencodejson [-3.0e17]                # yields [-3e+17]\nmy $value = 5; encodejson [$value]  # yields [5]\n\n# used as string, so dump as string\nprint $value;\nencodejson [$value]                 # yields [\"5\"]\n\n# undef becomes null\nencodejson [undef]                  # yields [null]\n\nYou can force the type to be a string by stringifying it:\n\nmy $x = 3.1; # some variable containing a number\n\"$x\";        # stringified\n$x .= \"\";    # another, more awkward way to stringify\nprint $x;    # perl does it for you, too, quite often\n\nYou can force the type to be a number by numifying it:\n\nmy $x = \"3\"; # some variable containing a string\n$x += 0;     # numify it, ensuring it will be dumped as a number\n$x *= 1;     # same thing, the choice is yours.\n\nYou can not currently force the type in other, less obscure, ways. Tell me if you need this\ncapability (but don't forget to explain why it's needed :).\n\nSince version 2.9101, JSON::PP uses a different number detection logic that converts a\nscalar that is possible to turn into a number safely. The new logic is slightly faster, and\ntends to help people who use older perl or who want to encode complicated data structure.\nHowever, this may results in a different JSON text from the one JSON::XS encodes (and thus\nmay break tests that compare entire JSON texts). If you do need the previous behavior for\nbetter compatibility or for finer control, set PERLJSONPPUSEB environmental variable to\ntrue before you \"use\" JSON.\n\nNote that numerical precision has the same meaning as under Perl (so binary to decimal\nconversion follows the same rules as in Perl, which can differ to other languages). Also,\nyour perl interpreter might expose extensions to the floating point numbers of your\nplatform, such as infinities or NaN's - these cannot be represented in JSON, and it is an\nerror to pass those in.\n\nJSON.pm backend modules trust what you pass to \"encode\" method (or \"encodejson\" function)\nis a clean, validated data structure with values that can be represented as valid JSON\nvalues only, because it's not from an external data source (as opposed to JSON texts you\npass to \"decode\" or \"decodejson\", which JSON backends consider tainted and don't trust). As\nJSON backends don't know exactly what you and consumers of your JSON texts want the\nunexpected values to be (you may want to convert them into null, or to stringify them with\nor without normalisation (string representation of infinities/NaN may vary depending on\nplatforms), or to croak without conversion), you're advised to do what you and your\nconsumers need before you encode, and also not to numify values that may start with values\nthat look like a number (including infinities/NaN), without validating.\n\nOBJECT SERIALISATION\nAs JSON cannot directly represent Perl objects, you have to choose between a pure JSON\nrepresentation (without the ability to deserialise the object automatically again), and a\nnonstandard extension to the JSON syntax, tagged values.\n\nSERIALISATION\nWhat happens when this module encounters a Perl object depends on the \"allowblessed\",\n\"convertblessed\" and \"allowtags\" settings, which are used in this order:\n\n1. \"allowtags\" is enabled and the object has a \"FREEZE\" method.\nIn this case, \"JSON\" creates a tagged JSON value, using a nonstandard extension to the JSON\nsyntax.\n\nThis works by invoking the \"FREEZE\" method on the object, with the first argument being the\nobject to serialise, and the second argument being the constant string \"JSON\" to distinguish\nit from other serialisers.\n\nThe \"FREEZE\" method can return any number of values (i.e. zero or more). These values and\nthe package/classname of the object will then be encoded as a tagged JSON value in the\nfollowing format:\n\n(\"classname\")[FREEZE return values...]\n\ne.g.:\n\n(\"URI\")[\"http://www.google.com/\"]\n(\"MyDate\")[2013,10,29]\n(\"ImageData::JPEG\")[\"Z3...VlCg==\"]\n\nFor example, the hypothetical \"My::Object\" \"FREEZE\" method might use the objects \"type\" and\n\"id\" members to encode the object:\n\nsub My::Object::FREEZE {\nmy ($self, $serialiser) = @;\n\n($self->{type}, $self->{id})\n}\n\n2. \"convertblessed\" is enabled and the object has a \"TOJSON\" method.\nIn this case, the \"TOJSON\" method of the object is invoked in scalar context. It must\nreturn a single scalar that can be directly encoded into JSON. This scalar replaces the\nobject in the JSON text.\n\nFor example, the following \"TOJSON\" method will convert all URI objects to JSON strings\nwhen serialised. The fact that these values originally were URI objects is lost.\n\nsub URI::TOJSON {\nmy ($uri) = @;\n$uri->asstring\n}\n\n3. \"allowblessed\" is enabled.\nThe object will be serialised as a JSON null value.\n\n4. none of the above\nIf none of the settings are enabled or the respective methods are missing, this module\nthrows an exception.\n\nDESERIALISATION\nFor deserialisation there are only two cases to consider: either nonstandard tagging was used,\nin which case \"allowtags\" decides, or objects cannot be automatically be deserialised, in which\ncase you can use postprocessing or the \"filterjsonobject\" or \"filterjsonsinglekeyobject\"\ncallbacks to get some real objects our of your JSON.\n\nThis section only considers the tagged value case: a tagged JSON object is encountered during\ndecoding and \"allowtags\" is disabled, a parse error will result (as if tagged values were not\npart of the grammar).\n\nIf \"allowtags\" is enabled, this module will look up the \"THAW\" method of the package/classname\nused during serialisation (it will not attempt to load the package as a Perl module). If there\nis no such method, the decoding will fail with an error.\n\nOtherwise, the \"THAW\" method is invoked with the classname as first argument, the constant\nstring \"JSON\" as second argument, and all the values from the JSON array (the values originally\nreturned by the \"FREEZE\" method) as remaining arguments.\n\nThe method must then return the object. While technically you can return any Perl scalar, you\nmight have to enable the \"allownonref\" setting to make that work in all cases, so better return\nan actual blessed reference.\n\nAs an example, let's implement a \"THAW\" function that regenerates the \"My::Object\" from the\n\"FREEZE\" example earlier:\n\nsub My::Object::THAW {\nmy ($class, $serialiser, $type, $id) = @;\n\n$class->new (type => $type, id => $id)\n}\n",
                "subsections": []
            },
            "ENCODING/CODESET FLAG NOTES": {
                "content": "This section is taken from JSON::XS.\n\nThe interested reader might have seen a number of flags that signify encodings or codesets -\n\"utf8\", \"latin1\" and \"ascii\". There seems to be some confusion on what these do, so here is a\nshort comparison:\n\n\"utf8\" controls whether the JSON text created by \"encode\" (and expected by \"decode\") is UTF-8\nencoded or not, while \"latin1\" and \"ascii\" only control whether \"encode\" escapes character\nvalues outside their respective codeset range. Neither of these flags conflict with each other,\nalthough some combinations make less sense than others.\n\nCare has been taken to make all flags symmetrical with respect to \"encode\" and \"decode\", that\nis, texts encoded with any combination of these flag values will be correctly decoded when the\nsame flags are used - in general, if you use different flag settings while encoding vs. when\ndecoding you likely have a bug somewhere.\n\nBelow comes a verbose discussion of these flags. Note that a \"codeset\" is simply an abstract set\nof character-codepoint pairs, while an encoding takes those codepoint numbers and *encodes*\nthem, in our case into octets. Unicode is (among other things) a codeset, UTF-8 is an encoding,\nand ISO-8859-1 (= latin 1) and ASCII are both codesets *and* encodings at the same time, which\ncan be confusing.\n\n\"utf8\" flag disabled\nWhen \"utf8\" is disabled (the default), then \"encode\"/\"decode\" generate and expect Unicode\nstrings, that is, characters with high ordinal Unicode values (> 255) will be encoded as\nsuch characters, and likewise such characters are decoded as-is, no changes to them will be\ndone, except \"(re-)interpreting\" them as Unicode codepoints or Unicode characters,\nrespectively (to Perl, these are the same thing in strings unless you do funny/weird/dumb\nstuff).\n\nThis is useful when you want to do the encoding yourself (e.g. when you want to have UTF-16\nencoded JSON texts) or when some other layer does the encoding for you (for example, when\nprinting to a terminal using a filehandle that transparently encodes to UTF-8 you certainly\ndo NOT want to UTF-8 encode your data first and have Perl encode it another time).\n\n\"utf8\" flag enabled\nIf the \"utf8\"-flag is enabled, \"encode\"/\"decode\" will encode all characters using the\ncorresponding UTF-8 multi-byte sequence, and will expect your input strings to be encoded as\nUTF-8, that is, no \"character\" of the input string must have any value > 255, as UTF-8 does\nnot allow that.\n\nThe \"utf8\" flag therefore switches between two modes: disabled means you will get a Unicode\nstring in Perl, enabled means you get an UTF-8 encoded octet/binary string in Perl.\n\n\"latin1\" or \"ascii\" flags enabled\nWith \"latin1\" (or \"ascii\") enabled, \"encode\" will escape characters with ordinal values >\n255 (> 127 with \"ascii\") and encode the remaining characters as specified by the \"utf8\"\nflag.\n\nIf \"utf8\" is disabled, then the result is also correctly encoded in those character sets (as\nboth are proper subsets of Unicode, meaning that a Unicode string with all character values\n< 256 is the same thing as a ISO-8859-1 string, and a Unicode string with all character\nvalues < 128 is the same thing as an ASCII string in Perl).\n\nIf \"utf8\" is enabled, you still get a correct UTF-8-encoded string, regardless of these\nflags, just some more characters will be escaped using \"\\uXXXX\" then before.\n\nNote that ISO-8859-1-*encoded* strings are not compatible with UTF-8 encoding, while\nASCII-encoded strings are. That is because the ISO-8859-1 encoding is NOT a subset of UTF-8\n(despite the ISO-8859-1 *codeset* being a subset of Unicode), while ASCII is.\n\nSurprisingly, \"decode\" will ignore these flags and so treat all input values as governed by\nthe \"utf8\" flag. If it is disabled, this allows you to decode ISO-8859-1- and ASCII-encoded\nstrings, as both strict subsets of Unicode. If it is enabled, you can correctly decode UTF-8\nencoded strings.\n\nSo neither \"latin1\" nor \"ascii\" are incompatible with the \"utf8\" flag - they only govern\nwhen the JSON output engine escapes a character or not.\n\nThe main use for \"latin1\" is to relatively efficiently store binary data as JSON, at the\nexpense of breaking compatibility with most JSON decoders.\n\nThe main use for \"ascii\" is to force the output to not contain characters with values > 127,\nwhich means you can interpret the resulting string as UTF-8, ISO-8859-1, ASCII, KOI8-R or\nmost about any character set and 8-bit-encoding, and still get the same data structure back.\nThis is useful when your channel for JSON transfer is not 8-bit clean or the encoding might\nbe mangled in between (e.g. in mail), and works because ASCII is a proper subset of most\n8-bit and multibyte encodings in use in the world.\n",
                "subsections": []
            },
            "BACKWARD INCOMPATIBILITY": {
                "content": "Since version 2.90, stringification (and string comparison) for \"JSON::true\" and \"JSON::false\"\nhas not been overloaded. It shouldn't matter as long as you treat them as boolean values, but a\ncode that expects they are stringified as \"true\" or \"false\" doesn't work as you have expected\nany more.\n\nif (JSON::true eq 'true') {  # now fails\n\nprint \"The result is $JSON::true now.\"; # => The result is 1 now.\n\nAnd now these boolean values don't inherit JSON::Boolean, either. When you need to test a value\nis a JSON boolean value or not, use \"JSON::isbool\" function, instead of testing the value\ninherits a particular boolean class or not.\n",
                "subsections": []
            },
            "BUGS": {
                "content": "Please report bugs on backend selection and additional features this module provides to RT or\nGitHub issues for this module:\n\n<https://rt.cpan.org/Public/Dist/Display.html?Queue=JSON>\n\n<https://github.com/makamaka/JSON/issues>\n\nAs for bugs on a specific behavior, please report to the author of the backend module you are\nusing.\n\nAs for new features and requests to change common behaviors, please ask the author of JSON::XS\n(Marc Lehmann, <schmorp[at]schmorp.de>) first, by email (important!), to keep compatibility\namong JSON.pm backends.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "JSON::XS, Cpanel::JSON::XS, JSON::PP for backends.\n\nJSON::MaybeXS, an alternative that prefers Cpanel::JSON::XS.\n\n\"RFC4627\"(<http://www.ietf.org/rfc/rfc4627.txt>)\n\nRFC7159 (<http://www.ietf.org/rfc/rfc7159.txt>)\n\nRFC8259 (<http://www.ietf.org/rfc/rfc8259.txt>)\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Makamaka Hannyaharamitu, <makamaka[at]cpan.org>\n\nJSON::XS was written by Marc Lehmann <schmorp[at]schmorp.de>\n\nThe release of this new version owes to the courtesy of Marc Lehmann.\n",
                "subsections": []
            },
            "CURRENT MAINTAINER": {
                "content": "Kenichi Ishigaki, <ishigaki[at]cpan.org>\n",
                "subsections": []
            },
            "COPYRIGHT AND LICENSE": {
                "content": "Copyright 2005-2013 by Makamaka Hannyaharamitu\n\nMost of the documentation is taken from JSON::XS by Marc Lehmann\n\nThis library is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n",
                "subsections": []
            }
        }
    }
}