Performance issue in conversion of json to bson

Please check the corresponding piece of code for your reference:

List documents = new ArrayList<>();

for(int i=0; i< jsonArray.size(); i++) {

documents.add(Document.parse(jsonArray.get(i).toString()));

}

The above mentioned code is a snippet from a java function, we take as an argument, a com.google.gson.JsonArray and then inside a loop, we convert each of the json elements, which are very small in size, to corresponding org.bson.Document document and then after the loop is completed, we use the com.mongodb.client.MongoCollection.insertMany method to insert all the above created documents.

Now, the problem which we are facing is that the conversion of json to...

Read More »

By: StackOverFlow - 6 days ago

Related Posts