I found a good way to achieve this:
(ArrayList<Document>) JSON.parse("[String json array]");
I had a problem with this because I need to add a property to this document, which is a Json array:
Document objAddendumVersion = new Document(); objAddendumVersion.append("_id", new ObjectId()); objAddendumVersion.append("Array", My Array here!);
But the problem is that Document.parse () does not work with arrays, so I can solve it using the line above. So the final code is:
Document objAddendumVersion = new Document(); objAddendumVersion.append("_id", new ObjectId()); objAddendumVersion.append("Array", (ArrayList<Document>) JSON.parse("[String json array]"));
And it works great. Yes, I know that there are more effective ways to do this, but at the moment I'm using it.
I am expecting it to be useful for someone with the same problem.
source share