BSON::Bytes(3pm)
π BSON::Bytes π
okay bestie, welcome to BSON::Bytes β it's a BSON type wrapper for binary byte strings, and it's from the User Contributed Perl Documentation section of the manual (so yeah, BSON::Bytes(3pm), we know her π
).
β¨ VERSION β¨
version v1.12.2 β this is the one, no cap π
β¨ SYNOPSIS β¨
like, here's the whole vibe in four lines:
use BSON::Types ':all';
$bytes = bson_bytes( $bytestring );
$bytes = bson_bytes( $bytestring, $subtype );
that's it. that's the whole thing. she's efficient π¦
β¨ DESCRIPTION β¨
so basically? this module is a BSON type wrapper for binary data β and the binary data in question is represented as a string of bytes. that's the whole job. iconic, honestly. π
β¨ ATTRIBUTES β¨
πΈ data
a scalar, and you gotta interpret it as bytes. (like, if you've got "character" data, you should encode it to bytes first, bestie β don't just yeet your text in there raw.) it defaults to the empty string. π«Ά
πΈ subtype
a numeric BSON subtype, and it's gotta live between 0 and 255. defaults to 0, and honestly you generally should not be messing with it. oh and also β subtypes 128 to 255 are the "user-defined" ones. iykyk β¨
β¨ METHODS β¨
π¦ TO_JSON
returns a Base64 encoded string that's equivalent to the data attribute. slay.
BUT β and this is the plot twist β if the BSON_EXTJSON option is true, then instead it'll be compatible with MongoDB's extended JSON format (link: https://github.com/mongodb/specifications/blob/master/source/extended-json.rst), which represents it as a document like this:
{"$binary" : { "base64": "<base64 data>", "subType" : "<type>"} }
see how it's giving structured? π
β¨ OVERLOADING β¨
the stringification operator ("") is overloaded to return the binary data, and fallback overloading is enabled. periodt. π
β¨ AUTHORS β¨
these are the legends who made it happen π«Ά
- David Golden
<david@mongodb.com> - Stefan G.
<minimalist@lavabit.com>
β¨ COPYRIGHT AND LICENSE β¨
This software is Copyright (c) 2020 by Stefan G. and MongoDB, Inc.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
so yeah, go wild, it's free software π
okay that's the whole page, bestie!! this was rendered by perl v5.30.3 back on 2020-08-14, and that's your official BSON::Bytes(3pm) sign-off β love u, go encode some bytes, mwah ππ§ββοΈ
π¦ where this page comes from
- debian bookworm: libbson-perl 1.12.2-1 Β· Apache-2.0
- ubuntu jammy: libbson-perl 1.12.2-1 Β· Apache-2.0
- ubuntu noble: libbson-perl 1.12.2-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms