Hello,
I've been searching this information for a couple of hour, and as it's now well documented, i publish solution to prevent other people losing to much time for same need.
Mongodb odm in a symfony 5 project.
How to annotate type in Document class for allowing array to be correctly interpreted and correctly converted to json in the mongo database?
https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/2.1/reference/basic-mapping.html
We see as basic mapping types:

I've arrays to set with odm, to be converted in json.
Tried string, json_encoded string, raw... Nothing were ok, always converted to a string in mongo, so impossible to find on the array values in mongo: useless.
From the document site, nothing else about arrays, only customs types.
After a couple of hour of searching and trying, there 2 other types useful in that purpose: collection and hash types:
/**
* @MongoDB\Field(type="hash")
*/
protected $vmdata;
public function getVmdata() {
return $this->vmdata;
}
public function setVmdata($vmdata) {
$this->vmdata = $vmdata;
return;
}
Now, when i set:
$template->setVmdata($vmdata);
$vmdata being a php associative array, now it's correctly converted to a good json content rightly inserted in mongo.
Hope it helps friends, see you!
Have you read my other posts, click here!
Follow me on publish0x, and on twitter!
See you all!