Mango BSON documents as Extended JSON
use 5.010;
use Mojo::Base -strict;
use Mango::BSON ();
use Mojo::Util ();
use re (); # regexp_pattern()
use JSON::XS ();
use Exporter 5.57 'im
port';
our @EXPORT_OK = qw(to_extjson);
sub to_extjson {
my $doc = shift;
state $encoder = JSON::XS->new->convert_blessed(1);
my %opts = (pretty=>0,@_);
$encoder->$_($opts{$_}) for qw
ngo::BSON::BINARY_UUID(),
'user_defined' => Mango::BSON::BINARY_USER_DEFINED(),
);
my %TO_EXTJSON = (
# bson_bin
'Mango::BSON::Binary' => sub {
my $bindata = Mojo::Util::b64_enco