php8.5
Home/ Manual/ bson / document/ MongoDB\BSON\Document::fromJSON

MongoDB\BSON\Document::fromJSON

PHP function Edit on GitHub ✎

(mongodb >=1.16.0)

Construct a new document instance from a JSON string

Description

MongoDB\BSON\Document::fromJSON(string $json): MongoDB\BSON\Document

Converts an extended JSON string to its BSON representation.

Parameters

json (string)

JSON value to be converted.

Return Values

Returns a new MongoDB\BSON\Document instance.

Errors/Exceptions

  • Throws MongoDB\Driver\Exception\UnexpectedValueException if the JSON value cannot be converted to a BSON document (e.g. due to a syntax error).

See Also

  • MongoDB\BSON\Document::fromPHP
  • MongoDB\BSON\Document::fromBSON
  • MongoDB Extended JSON
  • BSON Types

Source: reference/mongodb/bson/document/fromjson.xml · from the official PHP manual (php/doc-en)