{
    "content": [
        {
            "type": "text",
            "text": "# JSON::MaybeXS (perldoc)\n\n## NAME\n\nJSON::MaybeXS - Use Cpanel::JSON::XS with a fallback to JSON::XS and JSON::PP\n\n## SYNOPSIS\n\nuse JSON::MaybeXS;\nmy $datastructure = decodejson($jsoninput);\nmy $jsonoutput = encodejson($datastructure);\nmy $json = JSON()->new;\nmy $jsonwithargs = JSON::MaybeXS->new(utf8 => 1); # or { utf8 => 1 }\n\n## DESCRIPTION\n\nThis module first checks to see if either Cpanel::JSON::XS or JSON::XS (at at least version 3.0)\nis already loaded, in which case it uses that module. Otherwise it tries to load\nCpanel::JSON::XS, then JSON::XS, then JSON::PP in order, and either uses the first module it\nfinds or throws an error.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **EXPORTS**\n- **CONSTRUCTOR**\n- **BOOLEANS**\n- **CAVEATS**\n- **INSTALLATION**\n- **AUTHOR**\n- **CONTRIBUTORS**\n- **COPYRIGHT**\n- **LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "JSON::MaybeXS",
        "section": "",
        "mode": "perldoc",
        "summary": "JSON::MaybeXS - Use Cpanel::JSON::XS with a fallback to JSON::XS and JSON::PP",
        "synopsis": "use JSON::MaybeXS;\nmy $datastructure = decodejson($jsoninput);\nmy $jsonoutput = encodejson($datastructure);\nmy $json = JSON()->new;\nmy $jsonwithargs = JSON::MaybeXS->new(utf8 => 1); # or { utf8 => 1 }",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 12,
                "subsections": []
            },
            {
                "name": "EXPORTS",
                "lines": 64,
                "subsections": []
            },
            {
                "name": "CONSTRUCTOR",
                "lines": 16,
                "subsections": []
            },
            {
                "name": "BOOLEANS",
                "lines": 39,
                "subsections": []
            },
            {
                "name": "CAVEATS",
                "lines": 18,
                "subsections": []
            },
            {
                "name": "INSTALLATION",
                "lines": 13,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "CONTRIBUTORS",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "LICENSE",
                "lines": 2,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "JSON::MaybeXS - Use Cpanel::JSON::XS with a fallback to JSON::XS and JSON::PP\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use JSON::MaybeXS;\n\nmy $datastructure = decodejson($jsoninput);\n\nmy $jsonoutput = encodejson($datastructure);\n\nmy $json = JSON()->new;\n\nmy $jsonwithargs = JSON::MaybeXS->new(utf8 => 1); # or { utf8 => 1 }\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This module first checks to see if either Cpanel::JSON::XS or JSON::XS (at at least version 3.0)\nis already loaded, in which case it uses that module. Otherwise it tries to load\nCpanel::JSON::XS, then JSON::XS, then JSON::PP in order, and either uses the first module it\nfinds or throws an error.\n\nIt then exports the \"encodejson\" and \"decodejson\" functions from the loaded module, along with\na \"JSON\" constant that returns the class name for calling \"new\" on.\n\nIf you're writing fresh code rather than replacing JSON.pm usage, you might want to pass options\nas constructor args rather than calling mutators, so we provide our own \"new\" method that\nsupports that.\n",
                "subsections": []
            },
            "EXPORTS": {
                "content": "\"encodejson\", \"decodejson\" and \"JSON\" are exported by default; \"isbool\" is exported on\nrequest.\n\nTo import only some symbols, specify them on the \"use\" line:\n\nuse JSON::MaybeXS qw(encodejson decodejson isbool); # functions only\n\nuse JSON::MaybeXS qw(JSON); # JSON constant only\n\nTo import all available sensible symbols (\"encodejson\", \"decodejson\", and \"isbool\"), use\n\":all\":\n\nuse JSON::MaybeXS ':all';\n\nTo import all symbols including those needed by legacy apps that use JSON::PP:\n\nuse JSON::MaybeXS ':legacy';\n\nThis imports the \"tojson\" and \"fromjson\" symbols as well as everything in \":all\". NOTE: This\nis to support legacy code that makes extensive use of \"tojson\" and \"fromjson\" which you are\nnot yet in a position to refactor. DO NOT use this import tag in new code, in order to avoid the\ncrawling horrors of getting UTF-8 support subtly wrong. See the documentation for JSON for\nfurther details.\n\nencodejson\nThis is the \"encodejson\" function provided by the selected implementation module, and takes a\nperl data structure which is serialised to JSON text.\n\nmy $jsontext = encodejson($datastructure);\n\ndecodejson\nThis is the \"decodejson\" function provided by the selected implementation module, and takes a\nstring of JSON text to deserialise to a perl data structure.\n\nmy $datastructure = decodejson($jsontext);\n\ntojson, fromjson\nSee JSON for details. These are included to support legacy code only.\n\nJSON\nThe \"JSON\" constant returns the selected implementation module's name for use as a class name -\nso:\n\nmy $jsonobj = JSON()->new; # returns a Cpanel::JSON::XS or JSON::PP object\n\nand that object can then be used normally:\n\nmy $datastructure = $jsonobj->decode($jsontext); # etc.\n\nThe use of parentheses here is optional, and only used as a hint to the reader that this use of\n\"JSON\" is a *subroutine* call, *not* a class name.\n\nisbool\n$isboolean = isbool($scalar)\n\nReturns true if the passed scalar represents either \"true\" or \"false\", two constants that act\nlike 1 and 0, respectively and are used to represent JSON \"true\" and \"false\" values in Perl.\n\nSince this is a bare sub in the various backend classes, it cannot be called as a class method\nlike the other interfaces; it must be called as a function, with no invocant. It supports the\nrepresentation used in all JSON backends.\n\nAvailable since version 1.002004.\n",
                "subsections": []
            },
            "CONSTRUCTOR": {
                "content": "new\nWith JSON::PP, JSON::XS and Cpanel::JSON::XS you are required to call mutators to set options,\nsuch as:\n\nmy $json = $class->new->utf8(1)->pretty(1);\n\nSince this is a trifle irritating and noticeably un-perlish, we also offer:\n\nmy $json = JSON::MaybeXS->new(utf8 => 1, pretty => 1);\n\nwhich works equivalently to the above (and in the usual tradition will accept a hashref instead\nof a hash, should you so desire).\n\nThe resulting object is blessed into the underlying backend, which offers (at least) the methods\n\"encode\" and \"decode\".\n",
                "subsections": []
            },
            "BOOLEANS": {
                "content": "To include JSON-aware booleans (\"true\", \"false\") in your data, just do:\n\nuse JSON::MaybeXS;\nmy $true = JSON()->true;\nmy $false = JSON()->false;\n\nThe booleans are also available as subs or methods on JSON::MaybeXS.\n\nuse JSON::MaybeXS ();\nmy $true = JSON::MaybeXS::true;\nmy $true = JSON::MaybeXS->true;\nmy $false = JSON::MaybeXS::false;\nmy $false = JSON::MaybeXS->false;\n\nCONVERTING FROM JSON::Any\nJSON::Any used to be the favoured compatibility layer above the various JSON backends, but over\ntime has grown a lot of extra code to deal with legacy backends (e.g. JSON::Syck) that are no\nlonger needed. This is a rough guide of translating such code:\n\nChange code from:\n\nuse JSON::Any;\nmy $json = JSON::Any->new->objToJson($data);    # or tojson($data), or Dump($data)\n\nto:\n\nuse JSON::MaybeXS;\nmy $json = encodejson($data);\n\nChange code from:\n\nuse JSON::Any;\nmy $data = JSON::Any->new->jsonToObj($json);    # or fromjson($json), or Load($json)\n\nto:\n\nuse JSON::MaybeXS;\nmy $json = decodejson($data);\n",
                "subsections": []
            },
            "CAVEATS": {
                "content": "The \"new()\" method in this module is technically a factory, not a constructor, because the\nobjects it returns will *NOT* be blessed into the \"JSON::MaybeXS\" class.\n\nIf you are using an object returned by this module as a Moo(se) attribute, this type constraint\ncode:\n\nis 'json' => ( isa => 'JSON::MaybeXS' );\n\nwill *NOT* do what you expect. Instead, either rely on the \"JSON\" class constant described\nabove, as so:\n\nis 'json' => ( isa => JSON::MaybeXS::JSON() );\n\nAlternatively, you can use duck typing:\n\nuse Moose::Util::TypeConstraints 'ducktype';\nis 'json' => ( isa => Object , ducktype([qw/ encode decode /]));\n",
                "subsections": []
            },
            "INSTALLATION": {
                "content": "At installation time, Makefile.PL will attempt to determine if you have a working compiler\navailable, and therefore whether you are able to run XS code. If so, Cpanel::JSON::XS will be\nadded to the prerequisite list, unless JSON::XS is already installed at a high enough version.\nJSON::XS may also be upgraded to fix any incompatibility issues.\n\nBecause running XS code is not mandatory and JSON::PP (which is in perl core) is used as a\nfallback backend, this module is safe to be used in a suite of code that is fatpacked or\ninstalled into a restricted-resource environment.\n\nYou can also prevent any XS dependencies from being installed by setting \"PUREPERLONLY=1\" in\nMakefile.PL options (or in the \"PERLMMOPT\" environment variable), or using the \"--pp\" or\n\"--pureperl\" flags with the cpanminus client.\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "mst - Matt S. Trout (cpan:MSTROUT) <mst@shadowcat.co.uk>\n",
                "subsections": []
            },
            "CONTRIBUTORS": {
                "content": "*   Clinton Gormley <drtech@cpan.org>\n\n*   Karen Etheridge <ether@cpan.org>\n\n*   Kieren Diment <diment@gmail.com>\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Copyright (c) 2013 the \"JSON::MaybeXS\" \"AUTHOR\" and \"CONTRIBUTORS\" as listed above.\n",
                "subsections": []
            },
            "LICENSE": {
                "content": "This library is free software and may be distributed under the same terms as perl itself.\n",
                "subsections": []
            }
        }
    }
}