I am developing a function to import ChangStream into aws redshift. I need to convert the value of the composite field type (such as: BsonArray, BsonDocument) in mongodb into a JSON string.
The Java bson library can only convert BsonDocument to JSON string (using toJson method), but other composite field types such as BsonArray are not supported
For example, the following code
BsonArray bsonArray = new BsonArray();
bsonArray.add(new BsonString("apple"));
bsonArray.add(new BsonString("banana"));
bsonArray.add(new BsonString("orange"));
I want it to output as:
["apple","banana","orange"]