Libmongoc and Aggreagation

I’m trying to use $arrayToObject Aggregation command in Libmongoc, can anyone show the example, function to be called for this command.

Or, is there any way to insert/update the object in the object? without expanding to array? I want to maintain mapping mechanism of the data.
For Ex,
{
_id:ObjectId(“123456789”),
foo: { a:1}
}
into
{
_id:ObjectId(“123456789”),
foo: { a:1,b:2,c:3},
}