« MongoDB\BSON\PackedArray::offsetUnset
MongoDB\BSON\PackedArray::toPHP »

MongoDB\BSON\PackedArray::toCanonicalExtendedJSON

(mongodb >=1.20.0)

MongoDB\BSON\PackedArray::toCanonicalExtendedJSON — Returns the Canonical Extended JSON representation of the BSON array

説明

final public function MongoDB\BSON\PackedArray::toCanonicalExtendedJSON(): string

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   PackedArray   representation   Canonical   toCanonicalExtendedJSON   type   packedArray   offsetUnset   toPHP   mongodb   final   canonical   format   converted   back   without   loss   numeric   types   remain   differentiated   containing   ObjectId   fromPHP   numberInt
関連する関数・ページ:
mongodb-bson-packedarray.tostring   mongodb-bson-packedarray.torelaxedextendedjson   mongodb-bson-packedarray.tophp   class.mongodb-bson-packedarray   mongodb-bson-packedarray.construct   mongodb-bson-packedarray.fromphp