NAME

MongoDB::BSON - Tools for serializing and deserializing data in BSON form

VERSION

version v0.708.3.0

NAME

MongoDB::BSON - Encoding and decoding utilities (more to come)

ATTRIBUTES

looks_like_number

$MongoDB::BSON::looks_like_number = 1;
$collection->insert({age => "4"}); # stores 4 as an int

If this is set, the driver will be more aggressive about converting strings into numbers. Anything that Scalar::Util's looks_like_number would approve as a number will be sent to MongoDB as its numeric value.

Defaults to 0 (for backwards compatibility).

If you do not set this, you may be using strings more often than you intend to. See the MongoDB::DataTypes section for more info on the behavior of strings vs. numbers.

char

$MongoDB::BSON::char = ":";
$collection->query({"x" => {":gt" => 4}});

Can be used to set a character other than "$" to use for special operators.

Turn on/off UTF8 flag when return strings

# turn off utf8 flag on strings
$MongoDB::BSON::utf8_flag_on = 0;

Default is turn on, that compatible with version before 0.34.

If set to 0, will turn of utf8 flag on string attribute and return on bytes mode, meant same as :

utf8::encode($str)

Currently MongoDB return string with utf8 flag, on character mode , some people wish to turn off utf8 flag and return string on byte mode, it maybe help to display "pretty" strings.

NOTE:

If you turn off utf8 flag, the string length will compute as bytes, and is_utf8 will return false.

Return binary data as instances of MongoDB::BSON::Binary instead of string refs.

$MongoDB::BSON::use_binary = 1

For backwards compatibility, binary data is deserialized as a string ref. If you would like to have it deserialized as instances of MongoDB::BSON::Binary (to, say, preserve the subtype), set $MongoDB::BSON::use_binary to 1.

UNSUPPORTED

Return boolean values as integers

Previously, the MongoDB driver documented the $MongoDB::BSON::use_boolean global for toggling whether boolean BSON values were deserialized as integers or boolean objects. However, this value was actually never used and the driver always deserialized objects as boolean values. Rather than fix this and break people's code, instead this option is no longer supported. A future driver (v1.0.0 or later) will provide a means for customizing the deserialization of boolean BSON values without the use of a global variable.

AUTHORS

  • David Golden <david@mongodb.com>

  • Mike Friedman <friedo@friedo.com>

  • Kristina Chodorow <k.chodorow@gmail.com>

  • Florian Ragwitz <rafl@debian.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2015 by MongoDB, Inc..

This is free software, licensed under:

The Apache License, Version 2.0, January 2004