MongoDB\BSON\fromJSON

(mongodb >=1.0.0)

MongoDB\BSON\fromJSONRetourne la représentation BSON d'une valeur JSON

Description

MongoDB\BSON\fromJSON(string$json): string

Convertit une chaine » JSON étendu en sa représentation BSON..

Liste de paramètres

json (string)

Valeur JSON à convertir.

Valeurs de retour

Le document sérialisé BSON en tant que chaîne binaire.

Erreurs / Exceptions

Exemples

Exemple #1 Exemple avec MongoDB\BSON\fromJSON()

<?php

$json
= '{ "_id": { "$oid": "563143b280d2387c91807965" } }';
$bson = MongoDB\BSON\fromJSON($json);
$value = MongoDB\BSON\toPHP($bson);
var_dump($value);

?>

L'exemple ci-dessus va afficher :

object(stdClass)#2 (1) { ["_id"]=> object(MongoDB\BSON\ObjectId)#1 (1) { ["oid"]=> string(24) "563143b280d2387c91807965" } }

Voir aussi

To Top