BSONArrayBuilder arr; arr.append(1); arr.append("hello"); arr.append(3.14159);
BSONArrayBuilder arr1; arr1.append(1); arr1.append(2); arr1.append(3); BSONArrayBuilder arr2; arr2.append("hello"); arr2.append(arr1.arr()); BSONObj obj = arr2.obj();In this example, we create two BSONArrayBuilder objects - arr1 and arr2. arr1 contains three integers and arr2 contains a string and a nested array arr1. We then convert arr2 to a BSONObj, which can be sent to MongoDB for insertion or update operations. Package: MongoDB C++ Driver.