If i run a query through mongoTemplate using spring boot for the data present in collection I get end response as
{
"_id": {
"timestamp": 1597241082,
"date": "2020-08-12T14:04:42.000+00:00"
},
"name": "Test Name",
"createdDate": "2020-08-12T14:04:42.218+00:00",
"updatedDate": "2020-08-12T14:04:42.218+00:00",
}
but I want to show end response like this
{
"_id": ObjectId("5f33f6fa36a1624b59db5310"),
"name": "Test Name",
"createdDate": ISODate("2020-08-12T19:34:42.218+05:30"),
"updatedDate": ISODate("2020-08-12T19:34:42.218+05:30")
}
I have tried but no luck with below approch.
Query query = Query.query(Criteria.where("name").is("Test Name"));
mongoTemplate.find(query, Document.class,collectionName);
mongoTemplate.find(query, Object.class,collectionName);
Is there any way to achieve this ?
I know end response is not a valid JSONObject but I want to fetch it like this.