MongoDB\BSON\PackedArray::toCanonicalExtendedJSON
(mongodb >=1.20.0)
MongoDB\BSON\PackedArray::toCanonicalExtendedJSON — Returns the Canonical Extended JSON representation of the BSON array
说明
Converts the BSON array to its » Canonical Extended JSON representation. The canonical format prefers type fidelity at the expense of concise output and is most suited for producing output that can be converted back to BSON without any loss of type information (e.g. numeric types will remain differentiated).
参数
此函数没有参数。
返回值
Returns a string containing the » Canonical Extended JSON representation of the BSON array.
示例
示例 #1 MongoDB\BSON\PackedArray::toCanonicalExtendedJSON() example
<?php
$array = [
'foo',
123,
4294967295,
new MongoDB\BSON\ObjectId('56315a7c6118fd1b920270b1'),
];
$packedArray = MongoDB\BSON\PackedArray::fromPHP($array);
echo $packedArray->toCanonicalExtendedJSON(), "\n";
?>
以上示例会输出:
[ "foo", { "$numberInt" : "123" }, { "$numberLong" : "4294967295" }, { "$oid" : "56315a7c6118fd1b920270b1" } ]
参见
- MongoDB\BSON\PackedArray::fromJSON() - Construct a new BSON array instance from a JSON string
- MongoDB\BSON\PackedArray::toRelaxedExtendedJSON() - Returns the Relaxed Extended JSON representation of the BSON array
- MongoDB\BSON\toCanonicalExtendedJSON() - Returns the Canonical Extended JSON representation of a BSON value
- » Extended JSON Specification
- » BSON Types
+添加备注
用户贡献的备注
此页面尚无用户贡献的备注。
备份地址:http://www.lvesu.com/blog/php/mongodb-bson-packedarray.tocanonicalextendedjson.php