After a few tries, here I am: the correct type to do this is the Hash type. Our document has a response field that looks like this:
/**
* @MongoDB\Hash
*/
protected $response;
And the call to set the value is as follow:
$myRecord->setResponse(json_decode($result, true));
This is it!
Edit: As I had some issues to retrieve the stored values, I came to use mongodb callbacks :/
/**
* (...)
* @MongoDB\HasLifecycleCallbacks
*/
class Log
{
(...)
/** @MongoDB\PreLoad */
public function preLoad(array &$data)
{
$data["response"] = json_encode($data["response"]);
}
/** @MongoDB\PrePersist */
public function prePersist()
{
$a_json = json_decode($this->getResponse(), true);
$this->setResponse($a_json);
}
Which makes the set call straight, by the way:
$myRecord->setResponse($result);