Implements BSON specification.
Compatible with Perl 6 Rakudo Star 2012.01+.
my $b = BSON.new;
my Buf $encoded = $b.encode(
{
"_id" => BSON::ObjectId.new( "4e4987edfed4c16f8a56ed1d" ),
"some string" => "foo",
"some number" => 123,
"some array" => [ ],
"some hash" => { },
"some bool" => Bool::True,
}
);
my $decoded = $b.decode( $encoded );
Perl6 <=> BSON
Str <=> UTF-8 string
Int <=> 32-bit Integer
Bool <=> Boolean "true" / "false"
Array <=> Array
Hash <=> Embedded document
BSON::ObjectId <=> ObjectId
Rat
, Real
- Not Yet Implemented
BSON::ObjectId
- Internal representation is 12 bytes,
but to keep it consistent with MongoDB presentation described in
ObjectId spec
constructor accepts string containing 12 hex pairs:
BSON::ObjectId.new( '4e4987edfed4c16f8a56ed1d' )
Internal Buf
can be reached by .Buf
accessor.
Method .perl
is available for easy debug.
##LICENSE
Released under Artistic License 2.0.
You can find me (and many awesome people who helped me to develop this module) on irc.freenode.net #perl6 channel as bbkr.