# The MongoDB\BSON\Document class

(mongodb >=1.16.0)

## Introduction

Represents a BSON document. This class is used when reading data as raw BSON and cannot be modified.

## Class synopsis

final class MongoDB\BSON\Document implements MongoDB\BSON\Type, ArrayAccess, IteratorAggregate {
/* Methods */
final private __construct()
final static public fromBSON(string `$bson`): MongoDB\BSON\Document
final static public fromJSON(string `$json`): MongoDB\BSON\Document
final static public fromPHP(object|array `$value`): MongoDB\BSON\Document
final public get(string `$key`): mixed
final public getIterator(): MongoDB\BSON\Iterator
final public has(string `$key`): bool
final public offsetExists(mixed `$key`): bool
final public offsetGet(mixed `$key`): mixed
final public offsetSet(mixed `$key`, mixed `$value`): void
final public offsetUnset(mixed `$key`): void
final public toCanonicalExtendedJSON(): string
final public toPHP(?array `$typeMap` = `null`): array|object
final public toRelaxedExtendedJSON(): string
final public __toString(): string
}

## Changelog

Version | Description
--- | ---
PECL mongodb 2.0.0 | This class no longer implements the Serializable interface.
PECL mongodb 1.17.0 | Implements MongoDB\BSON\Type.

## Table of Contents

- MongoDB\BSON\Document::__construct — Construct a new BSON document (unused)
- MongoDB\BSON\Document::fromBSON — Construct a new document instance from a BSON string
- MongoDB\BSON\Document::fromJSON — Construct a new document instance from a JSON string
- MongoDB\BSON\Document::fromPHP — Construct a new document instance from PHP data
- MongoDB\BSON\Document::get — Returns the value of a key in the document
- MongoDB\BSON\Document::getIterator — Returns an iterator for the BSON document
- MongoDB\BSON\Document::has — Returns whether a key is present in the document
- MongoDB\BSON\Document::offsetExists — Returns whether a key is present in the document
- MongoDB\BSON\Document::offsetGet — Returns the value of a key in the document
- MongoDB\BSON\Document::offsetSet — Implementation of ArrayAccess
- MongoDB\BSON\Document::offsetUnset — Implementation of ArrayAccess
- MongoDB\BSON\Document::toCanonicalExtendedJSON — Returns the Canonical Extended JSON representation of the BSON document
- MongoDB\BSON\Document::toPHP — Returns the PHP representation of the BSON document
- MongoDB\BSON\Document::toRelaxedExtendedJSON — Returns the Relaxed Extended JSON representation of the BSON document
- MongoDB\BSON\Document::__toString — Returns the string representation of this BSON Document

`↑` and `↓` to navigate • `Enter` to select • `Esc` to close • `/` to open