Construct a new document instance from a JSON string

# MongoDB\BSON\Document::fromJSON

(mongodb >=1.16.0)

MongoDB\BSON\Document::fromJSON — Construct a new document instance from a JSON string

### Beschreibung

final static public function MongoDB\BSON\Document::fromJSON(string `$json`): MongoDB\BSON\Document

Converts an » extended JSON string to its BSON representation.

### Parameter-Liste

`json` (string)
  JSON value to be converted.

### Rückgabewerte

Returns a new MongoDB\BSON\Document instance.

### Fehler/Exceptions

- Wirft eine MongoDB\Driver\Exception\InvalidArgumentException, wenn beim Analysieren von Argumenten ein Fehler auftritt.
- Throws MongoDB\Driver\Exception\UnexpectedValueException if the JSON value cannot be converted to a BSON document (e.g. due to a syntax error).

### Siehe auch

- MongoDB\BSON\Document::fromPHP() - Construct a new document instance from PHP data
- MongoDB\BSON\Document::fromBSON() - Construct a new document instance from a BSON string
- » MongoDB Extended JSON
- » BSON Types

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