MongoDB\BSON\toJSONReturns the JSON representation of a BSON value
&reftitle.description;
stringMongoDB\BSON\toJSONstringbson
Converts a BSON string to its
extended JSON
representation.
&reftitle.parameters;
bson (string)
BSON value to be converted.
&reftitle.returnvalues;
The converted JSON value.
&reftitle.errors;
Throws
MongoDB\Driver\Exception\UnexpectedValueException if
the input did not contain exactly one BSON document. Possible reasons
include, but are not limited to, invalid BSON, extra data (after reading one
BSON document), or an unexpected
libbson error.
&reftitle.examples;
MongoDB\BSON\toJSON example
new MongoDB\BSON\ObjectId('56315a7c6118fd1b920270b1')];
$bson = MongoDB\BSON\fromPHP($document);
echo MongoDB\BSON\toJSON($bson), "\n";
?>
]]>
&example.outputs;
&reftitle.seealso;
MongoDB\BSON\fromJSONMongoDB Extended JSONMongoDB BSON