MongoDB\BSON\toJSON
(mongodb >=1.0.0)
MongoDB\BSON\toJSON — Returns the JSON representation of a BSON value
Описание
string MongoDB\BSON\toJSON
( string
$bson
)Converts a BSON string to its » extended JSON representation.
Список параметров
-
bson
(string) -
BSON value to be converted.
Возвращаемые значения
The converted JSON value.
Ошибки
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.
Примеры
Пример #1 MongoDB\BSON\toJSON() example
<?php
$document = ['_id' => new MongoDB\BSON\ObjectId('56315a7c6118fd1b920270b1')];
$bson = MongoDB\BSON\fromPHP($document);
echo MongoDB\BSON\toJSON($bson), "\n";
?>
Результат выполнения данного примера:
{ "_id" : { "$oid" : "56315a7c6118fd1b920270b1" } }
Смотрите также
- MongoDB\BSON\fromJSON() - Returns the BSON representation of a JSON value
- » MongoDB Extended JSON
- » MongoDB BSON
Коментарии
404 Not Found