Group
Extension

Matches 17

BSON ( M/MO/MONGODB/BSON-v1.12.2.tar.gz, MONGODB, 2020; MetaCPAN )
BSON/lib/BSON.pm ( view source; MetaCPAN )
PP, so that modules can pick up right version of helpers
use BSON::Types (); # loads types for extjson inflation

#--------------------------------------------------------------------------#
# public 
method inflate_extjson (DEPRECATED)
#pod
#pod This legacy method does not follow the L<MongoDB Extended JSON|https://github.com/mongodb/specifications/blob/master/source/extended-json.rst>
#pod specif
ication.
#pod
#pod Use L</extjson_to_perl> instead.
#pod
#pod =cut

sub inflate_extjson {
    my ( $self, $hash ) = @_;

    for my $k ( keys %$hash ) {
        my $v = $hash->{$k};
        if ( subst
BSON ( M/MO/MONGODB/BSON-v1.12.2.tar.gz, MONGODB, 2020; MetaCPAN )
BSON/lib/BSON/Bytes.pm ( view source; MetaCPAN )
 TO_JSON
#pod
#pod Returns Base64 encoded string equivalent to the data attribute.
#pod
#pod If the C<BSON_EXTJSON> option is true, it will instead be compatible with
#pod MongoDB's L<extended JSON|ht
ce/extended-json.rst>
#pod format, which represents it as a document as follows:
#pod
#pod     {"$binary" : { "base64": "<base64 data>", "subType" : "<type>"} }
#pod
#pod =cut

sub TO_JSON {
    retur
n MIME::Base64::encode_base64($_[0]->{data}, "") unless $ENV{BSON_EXTJSON};

    my %data;
    tie( %data, 'Tie::IxHash' );
    $data{base64} = MIME::Base64::encode_base64($_[0]->{data}, "");
    $dat
BSON ( M/MO/MONGODB/BSON-v1.12.2.tar.gz, MONGODB, 2020; MetaCPAN )
BSON/lib/BSON/Code.pm ( view source; MetaCPAN )
 TO_JSON
#pod
#pod If the C<BSON_EXTJSON> option is true, returns a hashref compatible with
#pod MongoDB's L<extended JSON|https://github.com/mongodb/specifications/blob/master/source/extended-json.rs
e C<BSON_EXTJSON> option is false, an error is thrown, as this value
#pod can't otherwise be represented in JSON.
#pod
#pod =cut

sub TO_JSON {
    require BSON;
    if ( $ENV{BSON_EXTJSON} ) {
      
$scope'} = BSON->perl_to_extjson($_[0]->{scope})
            if defined $_[0]->{scope};
        return \%data;
    }

    Carp::croak( "The value '$_[0]' is illegal in JSON" );
}

1;

=pod

=encoding 
BSON ( M/MO/MONGODB/BSON-v1.12.2.tar.gz, MONGODB, 2020; MetaCPAN )
BSON/lib/BSON/Timestamp.pm ( view source; MetaCPAN )
 TO_JSON
#pod
#pod If the C<BSON_EXTJSON> option is true, returns a hashref compatible with
#pod MongoDB's L<extended JSON|https://github.com/mongodb/specifications/blob/master/source/extended-json.rs
pod If the C<BSON_EXTJSON> option is false, an error is thrown, as this value
#pod can't otherwise be represented in JSON.
#pod
#pod =cut

sub TO_JSON {
    if ( $ENV{BSON_EXTJSON} ) {
        my %dat
      return { '$timestamp' => \%data };
    }

    Carp::croak( "The value '$_[0]' is illegal in JSON" );
}

sub _cmp {
    my ( $l, $r, $swap ) = @_;
    if ( !defined($l) || !defined($r) ) {
      
BSON ( M/MO/MONGODB/BSON-v1.12.2.tar.gz, MONGODB, 2020; MetaCPAN )
BSON/lib/BSON/MaxKey.pm ( view source; MetaCPAN )
 TO_JSON
#pod
#pod If the C<BSON_EXTJSON> option is true, returns a hashref compatible with
#pod MongoDB's L<extended JSON|https://github.com/mongodb/specifications/blob/master/source/extended-json.rs
pod If the C<BSON_EXTJSON> option is false, an error is thrown, as this value
#pod can't otherwise be represented in JSON.
#pod
#pod =cut

sub TO_JSON {
    if ( $ENV{BSON_EXTJSON} ) {
        return 
{ '$maxKey' => 1 };
    }

    croak( "The value '$_[0]' is illegal in JSON" );
}

1;

=pod

=encoding UTF-8

=head1 NAME

BSON::MaxKey - BSON type wrapper for MaxKey

=head1 VERSION

version v1.12.2
BSON ( M/MO/MONGODB/BSON-v1.12.2.tar.gz, MONGODB, 2020; MetaCPAN )
BSON/lib/BSON/Time.pm ( view source; MetaCPAN )
d =method TO_JSON
#pod
#pod Returns a string formatted by L</as_iso8601>.
#pod
#pod If the C<BSON_EXTJSON> option is true, it will instead be compatible with
#pod MongoDB's L<extended JSON|https://git
er/source/extended-json.rst>
#pod format, which represents it as a document as follows:
#pod
#pod
#pod If the C<BSON_EXTJSON> environment variable is true and the
#pod C<BSON_EXTJSON_RELAXED> environm
rns a hashref
#pod compatible with
#pod MongoDB's L<extended JSON|https://github.com/mongodb/specifications/blob/master/source/extended-json.rst>
#pod format, which represents it as a document as foll
BSON ( M/MO/MONGODB/BSON-v1.12.2.tar.gz, MONGODB, 2020; MetaCPAN )
BSON/lib/BSON/DBRef.pm ( view source; MetaCPAN )
 TO_JSON
#pod
#pod If the C<BSON_EXTJSON> option is true, returns a hashref compatible with
#pod MongoDB's L<extended JSON|https://github.com/mongodb/specifications/blob/master/source/extended-json.rs
C<BSON_EXTJSON> option is false, an error is thrown, as this value
#pod can't otherwise be represented in JSON.
#pod
#pod =cut

sub TO_JSON {
    my $self = shift;

    if ( $ENV{BSON_EXTJSON} ) {
   
d = $self->id;

        if (ref $id) {
            $id = $id->TO_JSON;
        }
        else {
            $id = BSON->perl_to_extjson($id);
        }

        my %data;
        tie( %data, 'Tie::IxH
BSON ( M/MO/MONGODB/BSON-v1.12.2.tar.gz, MONGODB, 2020; MetaCPAN )
BSON/lib/BSON/Binary.pm ( view source; MetaCPAN )
@data = @{ $self->data };
    return pack( 'l<C*', scalar(@data), $self->type, @data );
}

sub TO_JSON {
    my %data;
    tie( %data, 'Tie::IxHash' );
    $data{base64} = $_[0]->to_s;
    $data{subTy
ongly encouraged to use L<BSON::Bytes> instead.

=for Pod::Coverage new data type subtype to_s TO_JSON

=head1 AUTHORS

=over 4

=item *

David Golden <david@mongodb.com>

=item *

Stefan G. <minimali
BSON ( M/MO/MONGODB/BSON-v1.12.2.tar.gz, MONGODB, 2020; MetaCPAN )
BSON/lib/BSON/MinKey.pm ( view source; MetaCPAN )
 TO_JSON
#pod
#pod If the C<BSON_EXTJSON> option is true, returns a hashref compatible with
#pod MongoDB's L<extended JSON|https://github.com/mongodb/specifications/blob/master/source/extended-json.rs
pod If the C<BSON_EXTJSON> option is false, an error is thrown, as this value
#pod can't otherwise be represented in JSON.
#pod
#pod =cut

sub TO_JSON {
    if ( $ENV{BSON_EXTJSON} ) {
        return 
{ '$minKey' => 1 };
    }

    croak( "The value '$_[0]' is illegal in JSON" );
}

1;

=pod

=encoding UTF-8

=head1 NAME

BSON::MinKey - BSON type wrapper for MinKey

=head1 VERSION

version v1.12.2
BSON ( M/MO/MONGODB/BSON-v1.12.2.tar.gz, MONGODB, 2020; MetaCPAN )
BSON/lib/BSON/OID.pm ( view source; MetaCPAN )
O_JSON
#pod
#pod Returns a string for this OID, with the OID given as 24 hex digits.
#pod
#pod If the C<BSON_EXTJSON> option is true, it will instead be compatible with
#pod MongoDB's L<extended JSON|
d-json.rst>
#pod format, which represents it as a document as follows:
#pod
#pod     {"$oid" : "012345678901234567890123"}
#pod
#pod =cut

sub TO_JSON {
    return $_[0]->hex unless $ENV{BSON_EXTJSON}
.

=head2 TO_JSON

Returns a string for this OID, with the OID given as 24 hex digits.

If the C<BSON_EXTJSON> option is true, it will instead be compatible with
MongoDB's L<extended JSON|https://gith
BSON ( M/MO/MONGODB/BSON-v1.12.2.tar.gz, MONGODB, 2020; MetaCPAN )
BSON/lib/BSON/Int64.pm ( view source; MetaCPAN )
od TO_JSON
#pod
#pod On a 64-bit perl, returns the value as an integer.  On a 32-bit Perl, it
#pod will be returned as a Math::BigInt object, which will
#pod fail to serialize unless a C<TO_JSON> meth
the C<BSON_EXTJSON> environment variable is true and the
#pod C<BSON_EXTJSON_RELAXED> environment variable is false, returns a hashref
#pod compatible with
#pod MongoDB's L<extended JSON|https://githu
ob/master/source/extended-json.rst>
#pod format, which represents it as a document as follows:
#pod
#pod     {"$numberLong" : "223372036854775807"}
#pod
#pod =cut

sub TO_JSON {
    return int($_[0]->
BSON ( M/MO/MONGODB/BSON-v1.12.2.tar.gz, MONGODB, 2020; MetaCPAN )
BSON/lib/BSON/Int32.pm ( view source; MetaCPAN )
t32");
    }
}

#pod =method TO_JSON
#pod
#pod Returns the value as an integer.
#pod
#pod If the C<BSON_EXTJSON> environment variable is true and the
#pod C<BSON_EXTJSON_RELAXED> environment variable 
rns a hashref
#pod compatible with
#pod MongoDB's L<extended JSON|https://github.com/mongodb/specifications/blob/master/source/extended-json.rst>
#pod format, which represents it as a document as foll
#pod
#pod     {"$numberInt" : "42"}
#pod
#pod =cut

sub TO_JSON {
    return int($_[0]->{value}) if ! $ENV{BSON_EXTJSON} || $ENV{BSON_EXTJSON_RELAXED};
    return { '$numberInt' => "$_[0]->{value}" };
BSON ( M/MO/MONGODB/BSON-v1.12.2.tar.gz, MONGODB, 2020; MetaCPAN )
BSON/lib/BSON/Decimal128.pm ( view source; MetaCPAN )

}

#pod =method TO_JSON
#pod
#pod Returns the value as a string.
#pod
#pod If the C<BSON_EXTJSON> option is true, it will instead
#pod be compatible with MongoDB's L<extended JSON|https://github.com/
aster/source/extended-json.rst>
#pod format, which represents it as a document as follows:
#pod
#pod     {"$numberDecimal" : "2.23372036854775807E+57"}
#pod
#pod =cut

sub TO_JSON {
    return "" . $_
[0]->value unless $ENV{BSON_EXTJSON};
    return { '$numberDecimal' => "" . ($_[0]->value)  };
}

use overload (
    q{""}    => sub { $_[0]->value },
    fallback => 1,
);

1;

=pod

=encoding UTF-8
BSON ( M/MO/MONGODB/BSON-v1.12.2.tar.gz, MONGODB, 2020; MetaCPAN )
BSON/lib/BSON/Double.pm ( view source; MetaCPAN )
value} / 1.0 : 0.0;
}

#pod =method TO_JSON
#pod
#pod Returns a double.
#pod
#pod If the C<BSON_EXTJSON> environment variable is true and the
#pod C<BSON_EXTJSON_RELAXED> environment variable is false
rns a hashref
#pod compatible with
#pod MongoDB's L<extended JSON|https://github.com/mongodb/specifications/blob/master/source/extended-json.rst>
#pod format, which represents it as a document as foll
   {"$numberDouble" : "42.0"}
#pod
#pod If C<BSON_EXTJSON> is false and the value is 'Inf', '-Inf' or 'NaN'
#pod (which are illegal in regular JSON), then an exception is thrown.
#pod
#pod =cut

my $u
BSON ( M/MO/MONGODB/BSON-v1.12.2.tar.gz, MONGODB, 2020; MetaCPAN )
BSON/lib/BSON/DBPointer.pm ( view source; MetaCPAN )
ends 'BSON::DBRef';

sub TO_JSON {
    my $self = shift;

    if ( $ENV{BSON_EXTJSON} ) {

        my $id = $self->id;
        if (ref $id) {
            $id = $id->TO_JSON;
        }
        else {
 
           $id = BSON->perl_to_extjson($id);
        }

        my %data;
        tie( %data, 'Tie::IxHash' );
        $data{'$ref'} = $self->ref;
        $data{'$id'} = $id;
        $data{'$db'} = $s
or keys %$extra;

        return \%data;
    }

    Carp::croak( "The value '$self' is illegal in JSON" );
}

1;

=pod

=encoding UTF-8

=head1 NAME

BSON::DBPointer - Legacy BSON type wrapper for DBP
BSON ( M/MO/MONGODB/BSON-v1.12.2.tar.gz, MONGODB, 2020; MetaCPAN )
BSON/lib/BSON/Regex.pm ( view source; MetaCPAN )
 TO_JSON
#pod
#pod If the C<BSON_EXTJSON> option is true, returns a hashref compatible with
#pod MongoDB's L<extended JSON|https://github.com/mongodb/specifications/blob/master/source/extended-json.rs
pod If the C<BSON_EXTJSON> option is false, an error is thrown, as this value
#pod can't otherwise be represented in JSON.
#pod
#pod =cut

sub TO_JSON {
    if ( $ENV{BSON_EXTJSON} ) {
        my %dat
regularExpression' => \%data,
        };
    }

    Carp::croak( "The value '$_[0]' is illegal in JSON" );
}


1;

=pod

=encoding UTF-8

=head1 NAME

BSON::Regex - BSON type wrapper for regular expre
BSON ( M/MO/MONGODB/BSON-v1.12.2.tar.gz, MONGODB, 2020; MetaCPAN )
BSON/lib/BSON/String.pm ( view source; MetaCPAN )
s{value} = "$args{value}";

    return \%args;
}

#pod =method TO_JSON
#pod
#pod Returns value as a string.
#pod
#pod =cut

sub TO_JSON { return "$_[0]->{value}" }

use overload (
    # Unary
    q{bo
 be stringified during construction.  The default
is the empty string.

=head1 METHODS

=head2 TO_JSON

Returns value as a string.

=for Pod::Coverage BUILDARGS

=head1 OVERLOADING

The stringificatio

Powered by Groonga
Maintained by Kenichi Ishigaki <ishigaki@cpan.org>. If you find anything, submit it on GitHub.