PHP 8.4.1 Released!

MongoDB\BSON\PackedArray::toCanonicalExtendedJSON

(mongodb >=1.20.0)

MongoDB\BSON\PackedArray::toCanonicalExtendedJSONReturns the Canonical Extended JSON representation of the BSON array

Beschreibung

final public 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).

Parameter-Liste

Diese Funktion besitzt keine Parameter.

Rückgabewerte

Returns a string containing the » Canonical Extended JSON representation of the BSON array.

Beispiele

Beispiel #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";

?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

[ "foo", { "$numberInt" : "123" }, { "$numberLong" : "4294967295" }, { "$oid" : "56315a7c6118fd1b920270b1" } ]

Siehe auch

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top