Hi, I am new to mongodb and I want to convert JSONObject to Document and then save it to mongodb. Here is what I encoded. I get service api in json.
CloseableHttpResponse response = httpClient.execute(get); HttpEntity entity = response.getEntity(); JSONObject Rat = new JSONObject(EntityUtils.toString(entity));
then I want to save this Rat in mongodb as a document, and then paste it into mongodb or mysql, so that I can display it later. I thought something like
Document doc = new Document(....); coll.insertOne(doc); /*where coll is MongoCollection<Document> coll = db.getCollection("rates"); */
but how to make a conversion from JSONObject to Document?
source share