{
    "mode": "perldoc",
    "parameter": "BSON::Code",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/BSON%3A%3ACode/json",
    "generated": "2026-06-15T14:49:59Z",
    "synopsis": "use BSON::Types ':all';\n$code = bsoncode( $javascript );\n$code = bsoncode( $javascript, $scope );",
    "sections": {
        "NAME": {
            "content": "BSON::Code - BSON type wrapper for Javascript code\n",
            "subsections": []
        },
        "VERSION": {
            "content": "version v1.12.2\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use BSON::Types ':all';\n\n$code = bsoncode( $javascript );\n$code = bsoncode( $javascript, $scope );\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module provides a BSON type wrapper for the \"Javascript code\" type and the \"Javascript with\nScope\" BSON types.\n",
            "subsections": []
        },
        "ATTRIBUTES": {
            "content": "code\nA string containing Javascript code. Defaults to the empty string.\n\nscope\nAn optional hash reference containing variables in the scope of \"code\". Defaults to \"undef\".\n",
            "subsections": []
        },
        "METHODS": {
            "content": "length\nReturns the length of the \"code\" attribute.\n\nTOJSON\nIf the \"BSONEXTJSON\" option is true, returns a hashref compatible with MongoDB's extended JSON\n<https://github.com/mongodb/specifications/blob/master/source/extended-json.rst> format, which\nrepresents it as a document as follows:\n\n{\"$code\" : \"<code>\"}\n{\"$code\" : \"<code>\", \"$scope\" : { ... } }\n\nIf the \"BSONEXTJSON\" option is false, an error is thrown, as this value can't otherwise be\nrepresented in JSON.\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "*   David Golden <david@mongodb.com>\n\n*   Stefan G. <minimalist@lavabit.com>\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "This software is Copyright (c) 2020 by Stefan G. and MongoDB, Inc.\n\nThis is free software, licensed under:\n\nThe Apache License, Version 2.0, January 2004\n",
            "subsections": []
        }
    },
    "summary": "BSON::Code - BSON type wrapper for Javascript code",
    "flags": [],
    "examples": [],
    "see_also": []
}