{
    "content": [
        {
            "type": "text",
            "text": "# JSON (man)\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\nmodule uses JSON::XS by default, and when JSON::XS is not available, falls back on JSON::PP,\nwhich is in the Perl core since 5.14. If JSON::PP is not available either, this module then\nfalls back on JSON::backportPP (which is actually JSON::PP in a different .pm file) bundled\nin the same distribution as this module.  You can also explicitly specify to use\nCpanel::JSON::XS, a fork of JSON::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** (10 subsections)\n- **ADDITIONAL METHODS** (3 subsections)\n- **INCREMENTAL PARSING**\n- **MAPPING** (2 subsections)\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": "man",
        "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": 21
                    },
                    {
                        "name": "-convert_blessed_universally",
                        "lines": 27
                    },
                    {
                        "name": "-no_export",
                        "lines": 11
                    }
                ]
            },
            {
                "name": "FUNCTIONAL INTERFACE",
                "lines": 73,
                "subsections": []
            },
            {
                "name": "COMMON OBJECT-ORIENTED INTERFACE",
                "lines": 5,
                "subsections": [
                    {
                        "name": "new",
                        "lines": 11
                    },
                    {
                        "name": "ascii",
                        "lines": 22
                    },
                    {
                        "name": "latin1",
                        "lines": 25
                    },
                    {
                        "name": "utf8",
                        "lines": 27
                    },
                    {
                        "name": "pretty",
                        "lines": 6
                    },
                    {
                        "name": "indent",
                        "lines": 47
                    },
                    {
                        "name": "relaxed",
                        "lines": 39
                    },
                    {
                        "name": "canonical",
                        "lines": 241
                    },
                    {
                        "name": "encode",
                        "lines": 4
                    },
                    {
                        "name": "decode",
                        "lines": 18
                    }
                ]
            },
            {
                "name": "ADDITIONAL METHODS",
                "lines": 2,
                "subsections": [
                    {
                        "name": "backend",
                        "lines": 18
                    },
                    {
                        "name": "property",
                        "lines": 9
                    },
                    {
                        "name": "boolean",
                        "lines": 5
                    }
                ]
            },
            {
                "name": "INCREMENTAL PARSING",
                "lines": 84,
                "subsections": []
            },
            {
                "name": "MAPPING",
                "lines": 10,
                "subsections": [
                    {
                        "name": "JSON -> PERL",
                        "lines": 55
                    },
                    {
                        "name": "PERL -> JSON",
                        "lines": 180
                    }
                ]
            },
            {
                "name": "ENCODING/CODESET FLAG NOTES",
                "lines": 81,
                "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": 10,
                "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\nmodule uses JSON::XS by default, and when JSON::XS is not available, falls back on JSON::PP,\nwhich is in the Perl core since 5.14. If JSON::PP is not available either, this module then\nfalls back on JSON::backportPP (which is actually JSON::PP in a different .pm file) bundled\nin the same distribution as this module.  You can also explicitly specify to use\nCpanel::JSON::XS, a fork of JSON::XS by Reini Urban.\n\nAll these backend modules have slight incompatibilities between them, including extra\nfeatures that other modules don't support, but as long as you use only common features (most\nimportant ones are described below), migration from backend to backend should be reasonably\neasy. For details, 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,\nand if JSON::XS is not available, it falls back on JSON::PP, and then JSON::backportPP if\nJSON::PP is 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.\nWhen you do, the internal JSON::XS object is replaced with a newly created JSON::PP\nobject with the setting copied from the XS object, so that you can use JSON::PP flags\n(and its slower \"decode\"/\"encode\" methods) from then on. In other words, this is not\nsomething that allows you to hook JSON::XS to change its behavior while keeping its\nspeed. JSON::XS and JSON::PP objects are quite different (JSON::XS object is a blessed\nscalar reference, while JSON::PP object is a blessed hash reference), and can't share\ntheir internals.\n\nTo avoid needless overhead (by copying settings), you are advised not to use this option\nand just 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\nto encode 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\nbe found in the structure, in order to let the methods replace the objects with whatever\nscalar values the methods return.\n\nIf you need to serialise data structures that may contain arbitrary objects, it's\nprobably better to use other serialisers (such as Sereal or Storable for example), but if\nyou do want to use this module for that purpose, \"-convertblesseduniversally\" option\nmay help, which tweaks \"encode\" method of the backend to install \"UNIVERSAL::TOJSON\"\nmethod (locally) before encoding, so that all the objects that don't have their own\n\"TOJSON\" method can fall back on the method in the \"UNIVERSAL\" namespace. Note that you\nstill need to enable \"convertblessed\" flag to actually encode objects in a data\nstructure, and \"UNIVERSAL::TOJSON\" method installed by this option only converts blessed\nhash/array references into their unblessed clone (including private keys/values that are\nnot supposed to 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\n\"()\" to 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\nabove options, 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\nslower, and may expect/generate different stuff from what \"encodejson\" and \"decodejson\" do,\ndepending on their options. It's better just to use Object-Oriented interfaces than using\nthese two functions.\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\nthe limits of supported formats.\n",
                "subsections": [
                    {
                        "name": "new",
                        "content": "$json = JSON->new\n\nCreates a new JSON::XS-compatible backend object that can be used to de/encode JSON strings.\nAll boolean flags described below are by default disabled (with the exception of\n\"allownonref\", which 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"
                    },
                    {
                        "name": "ascii",
                        "content": "$json = $json->ascii([$enable])\n\n$enabled = $json->getascii\n\nIf $enable is true (or missing), then the \"encode\" method will not generate characters\noutside the code range 0..127 (which is ASCII). Any Unicode characters outside that range\nwill be escaped using either a single \\uXXXX (BMP characters) or a double \\uHHHH\\uLLLLL\nescape sequence, as per RFC4627. The resulting encoded JSON text can be treated as a native\nUnicode string, an ascii-encoded, latin1-encoded or UTF-8 encoded string, or any other\nsuperset of ASCII.\n\nIf $enable is false, then the \"encode\" method will not escape Unicode characters unless\nrequired by 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"
                    },
                    {
                        "name": "latin1",
                        "content": "$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\nas latin1 (or iso-8859-1), escaping any characters outside the code range 0..255. The\nresulting string can be treated as a latin1-encoded JSON text or a native Unicode string. The\n\"decode\" method will not be affected in any way by this flag, as \"decode\" by default expects\nUnicode, which is a strict superset of latin1.\n\nIf $enable is false, then the \"encode\" method will not escape Unicode characters unless\nrequired by 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\nwill not be escaped, resulting in a smaller encoded size. The disadvantage is that the\nresulting JSON text is encoded in latin1 (and must correctly be treated as such when storing\nand transferring), a rare encoding for JSON. It is therefore most useful when you want to\nstore data structures known to contain binary data efficiently in files or databases, not\nwhen talking to other JSON encoders/decoders.\n\nJSON->new->latin1->encode ([\"\\x{89}\\x{abc}\"]\n=> [\"\\x{89}\\\\u0abc\"]    # (perl syntax, U+abc escaped, U+89 not)\n"
                    },
                    {
                        "name": "utf8",
                        "content": "$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,\nas described 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.\nto UTF-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"
                    },
                    {
                        "name": "pretty",
                        "content": "$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"
                    },
                    {
                        "name": "indent",
                        "content": "$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\noutput, putting every array member or object/hash key-value pair into its own line, indenting\nthem properly.\n\nIf $enable is false, no newlines or indenting will be produced, and the resulting JSON text\nis guaranteed 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\nafter the \":\" 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"
                    },
                    {
                        "name": "relaxed",
                        "content": "$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\nsyntax (see below). \"encode\" will not be affected in any way. Be aware that this option makes\nyou accept invalid JSON texts as if they were valid!. I suggest only to use this option to\nparse application-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\nyou write JSON texts manually and want to be able to quickly append elements, so this\nextension accepts 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-\nspace and comments are allowed.\n\n[\n1, # this comment not allowed in JSON\n# neither this one...\n]\n"
                    },
                    {
                        "name": "canonical",
                        "content": "$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\ndifferently even if contains the same data, as key-value pairs have no inherent ordering in\nPerl.\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\nits corresponding string, number or null JSON value, which is an extension to RFC4627.\nLikewise, \"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\ngiven something that is not a JSON object or array.\n\nExample, encode a Perl scalar as JSON value with enabled \"allownonref\", resulting in an\ninvalid JSON 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\ncheck for the availability of the \"TOJSON\" method on the object's class. If found, it will\nbe called in 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\nother methods called by the Perl core (== not by the user of the object) are usually in upper\ncase letters 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\ncheck for the availability of the \"FREEZE\" method on the object's class. If found, it will be\nused to serialise the object into a nonstandard tagged JSON value (that JSON decoders cannot\ndecode).\n\nIt also causes \"decode\" to parse such tagged JSON values and deserialise them via a call to\nthe \"THAW\" method.\n\nIf $enable is false (the default), then \"encode\" will not consider this type of conversion,\nand tagged 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\n\"false\" will be decoded as a copy of $false, and JSON \"true\" will be decoded as $true (\"copy\"\nhere is the 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\nlike YAML, 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\nare set 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\nobject. The only argument is a reference to the newly-created hash. If the code references\nreturns a single scalar (which need not be a reference), this value (or rather a copy of it)\nis inserted into the deserialised data structure. If it returns an empty list (NOTE: not\n\"undef\", which is a valid scalar), the original deserialised hash will be inserted. This\nsetting can slow down decoding considerably.\n\nWhen $coderef is omitted or undefined, any existing callback will be removed and \"decode\"\nwill not 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\nonly ever be one callback for a given key.\n\nAs this callback gets called less often then the \"filterjsonobject\" one, decoding speed\nwill not usually suffer as much. Therefore, single-key objects make excellent targets to\nserialise Perl objects into, especially as single-key JSON objects are as close to the type-\ntagged value concept as JSON gets (it's basically an ID/VALUE tuple). Of course, JSON does\nnot support this in any way, so you need to make sure your data never looks like a serialised\nPerl 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\nto reach 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\nonly a 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\nno effect 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"
                    },
                    {
                        "name": "encode",
                        "content": "$jsontext = $json->encode($perlscalar)\n\nConverts the given Perl value or data structure to its JSON representation. Croaks on error.\n"
                    },
                    {
                        "name": "decode",
                        "content": "$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\ntrailing garbage after the first JSON object, it will silently stop parsing there and return\nthe number of 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"
                    }
                ]
            },
            "ADDITIONAL METHODS": {
                "content": "The following methods are for this module only.\n",
                "subsections": [
                    {
                        "name": "backend",
                        "content": "$backend = $json->backend\n\nSince 2.92, \"backend\" method returns an abstract backend module used currently, which should\nbe JSON::Backend::XS (which inherits JSON::XS or Cpanel::JSON::XS), or JSON::Backend::PP\n(which inherits 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"
                    },
                    {
                        "name": "property",
                        "content": "$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"
                    },
                    {
                        "name": "boolean",
                        "content": "$booleanobject = JSON->boolean($scalar)\n\nReturns $JSON::true if $scalar contains a true value, $JSON::false otherwise.  You can use\nthis as a full-qualified function (\"JSON::boolean($scalar)\").\n"
                    }
                ]
            },
            "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\nalways has to keep both JSON text and resulting Perl data structure in memory at one time, it\ndoes allow you to parse a JSON stream incrementally. It does so by accumulating text until it\nhas a full JSON object, which it then can decode. This process is similar to using\n\"decodeprefix\" to see if a full JSON object is available, but is much more efficient (and\ncan be implemented with a minimum of method calls).\n\nThis module will only attempt to parse the JSON text once it is sure it has enough text to\nget a decisive result, using a very simple but truly incremental parser. This means that it\nsometimes won't stop as early as the full parser, for example, it doesn't detect mismatched\nparentheses. The only thing it guarantees is that it starts decoding as soon as a\nsyntactically valid JSON text has been seen. This means you need to set resource limits (e.g.\n\"maxsize\") to ensure the parser 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\nthe stream 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\nstored in 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\".\nIf there 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\ncan find and return them, or the empty list otherwise. For this to work, there must be no\nseparators (other than whitespace) between the JSON objects or arrays, instead they must be\nconcatenated back-to-back. If an error occurs, an exception will be raised as in the scalar\ncontext case. Note 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\nmanipulate it. This only works when a preceding call to \"incrparse\" in scalar context\nsuccessfully returned an object. Under all other circumstances you must not call this\nfunction (I mean it.  although in simple tests it might actually work, it will fail under\nreal world conditions). As a special exception, you can also call this method before having\nparsed anything.\n\nThat means you can only use this function to look at or manipulate text before or after\ncomplete JSON 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\nand incremental parser state is left unchanged, to skip the text parsed so far and to reset\nthe parse 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\nequivalent).\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",
                "subsections": [
                    {
                        "name": "JSON -> PERL",
                        "content": "object\nA JSON object becomes a reference to a hash in Perl. No ordering of object keys is\npreserved (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\nrepresented by the same codepoints in the Perl string, so no manual decoding is\nnecessary.\n\nnumber\nA JSON number becomes either an integer, numeric (floating point) or string scalar in\nperl, depending on its range and any fractional parts. On the Perl level, there is no\ndifference between those as Perl handles all the conversion details, but an integer may\ntake slightly less memory and might represent more values exactly than floating point\nnumbers.\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\nonly guarantees 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\nto act 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,\nare tagged values. In this implementation, the tag must be a perl package/class name\nencoded as a JSON string, and the value must be a JSON array encoding optional\nconstructor arguments.\n\nSee \"OBJECT SERIALISATION\", below, for details.\n"
                    },
                    {
                        "name": "PERL -> JSON",
                        "content": "The mapping from Perl to JSON is slightly more difficult, as Perl is a truly typeless\nlanguage, so 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\n(or JSON 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\nsame backend), but this incurs a runtime overhead and is only rarely useful, e.g. when\nyou want to 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\nuse \"\\1\" and \"\\0\" directly if you want.\n\nblessed objects\nBlessed objects are not directly representable in JSON, but \"JSON::XS\" allows various\nways of 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\nto encode: this module will encode undefined scalars as JSON \"null\" values, scalars that\nhave last been used in a string context before encoding as JSON strings, and anything\nelse as number 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\nthis capability (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,\nand tends to help people who use older perl or who want to encode complicated data\nstructure. However, this may results in a different JSON text from the one JSON::XS\nencodes (and thus may break tests that compare entire JSON texts). If you do need the\nprevious behavior for better compatibility or for finer control, set PERLJSONPPUSEB\nenvironmental variable to true 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\"\nfunction) is a clean, validated data structure with values that can be represented as\nvalid JSON values only, because it's not from an external data source (as opposed to JSON\ntexts you pass to \"decode\" or \"decodejson\", which JSON backends consider tainted and\ndon't trust). As JSON backends don't know exactly what you and consumers of your JSON\ntexts want the unexpected values to be (you may want to convert them into null, or to\nstringify them with or without normalisation (string representation of infinities/NaN may\nvary depending on platforms), or to croak without conversion), you're advised to do what\nyou and your consumers need before you encode, and also not to numify values that may\nstart with values that 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\n\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\nJSON syntax.\n\nThis works by invoking the \"FREEZE\" method on the object, with the first argument being\nthe object to serialise, and the second argument being the constant string \"JSON\" to\ndistinguish it 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\"\nand \"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\n\nFor deserialisation there are only two cases to consider: either nonstandard tagging was\nused, in which case \"allowtags\" decides, or objects cannot be automatically be deserialised,\nin which case you can use postprocessing or the \"filterjsonobject\" or\n\"filterjsonsinglekeyobject\" callbacks 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\nnot part of the grammar).\n\nIf \"allowtags\" is enabled, this module will look up the \"THAW\" method of the\npackage/classname used during serialisation (it will not attempt to load the package as a\nPerl module). If there is 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\noriginally returned 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\nreturn an 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"
                    }
                ]
            },
            "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\nother, although 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\nthe same flags are used - in general, if you use different flag settings while encoding vs.\nwhen decoding you likely have a bug somewhere.\n\nBelow comes a verbose discussion of these flags. Note that a \"codeset\" is simply an abstract\nset of 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\nencoding, and ISO-8859-1 (= latin 1) and ASCII are both codesets and encodings at the same\ntime, which can 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\nbe done, 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\nUTF-16 encoded JSON texts) or when some other layer does the encoding for you (for\nexample, when printing to a terminal using a filehandle that transparently encodes to\nUTF-8 you certainly do NOT want to UTF-8 encode your data first and have Perl encode it\nanother 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\nas UTF-8, that is, no \"character\" of the input string must have any value > 255, as UTF-8\ndoes not allow that.\n\nThe \"utf8\" flag therefore switches between two modes: disabled means you will get a\nUnicode string in Perl, enabled means you get an UTF-8 encoded octet/binary string in\nPerl.\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\n(as both are proper subsets of Unicode, meaning that a Unicode string with all character\nvalues < 256 is the same thing as a ISO-8859-1 string, and a Unicode string with all\ncharacter values < 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 ASCII-\nencoded 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\nby the \"utf8\" flag. If it is disabled, this allows you to decode ISO-8859-1- and ASCII-\nencoded strings, as both strict subsets of Unicode. If it is enabled, you can correctly\ndecode UTF-8 encoded 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 >\n127, which means you can interpret the resulting string as UTF-8, ISO-8859-1, ASCII,\nKOI8-R or most about any character set and 8-bit-encoding, and still get the same data\nstructure back. This is useful when your channel for JSON transfer is not 8-bit clean or\nthe encoding might be mangled in between (e.g. in mail), and works because ASCII is a\nproper subset of most 8-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\n\"JSON::false\" has not been overloaded. It shouldn't matter as long as you treat them as\nboolean values, but a code that expects they are stringified as \"true\" or \"false\" doesn't\nwork as you have expected any 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\nvalue is a JSON boolean value or not, use \"JSON::isbool\" function, instead of testing the\nvalue inherits 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\nJSON::XS (Marc Lehmann, <schmorp[at]schmorp.de>) first, by email (important!), to keep\ncompatibility among 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\nas Perl itself.\n\n\n\nperl v5.32.1                                 2021-12-17                                    JSON(3pm)",
                "subsections": []
            }
        }
    }
}