MongoDB\BSON\Document::fromJSON

Construct a new document instance from a JSON string

Description

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

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\InvalidArgumentException on argument parsing errors.
  • 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