I have a problem I don't know how to convert the List<document>
to json :
public static List<Document> d() {
conexion c = new conexion();
List<Document> resultados = new ArrayList<>();
for (Document cur : c.table.find()){
resultados.add(cur);
}
return resultados;
}
there is an easier way according to the mongo documentation here
Thus, you are directly obtaining a complete list of json's for you to use, with the method you
toJson()
convert the table objects into json. at the end what you get is a string (" ") with jsonString
formatas something additional here is a similar question in english
To convert a Document to Json, use the toJson() method which gets a Json representation of the Document
To obtain all the tables of the document, it is done in this way:
You can also use a BasicDBList to save it and get the Json of the whole collection by
JSON.serialize()
: