MongoDB\BSON\fromJSON

(mongodb >=1.0.0)

MongoDB\BSON\fromJSONReturns the BSON representation of a JSON value

说锟斤拷

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

Converts an » extended JSON string to its BSON representation.

锟斤拷锟斤拷

json (string)

JSON value to be converted.

锟斤拷锟斤拷值

The serialized BSON document as a binary string.

锟斤拷锟斤拷锟届常

锟斤拷锟斤拷

Example #1 MongoDB\BSON\fromJSON() example

<?php

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

?>

锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�

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

锟轿硷拷