Why do I get the "\" everywhere ?
Method I Use:
@RequestMapping(value = '/showFromMongo', method = RequestMethod.GET)
def showFromMongoDB() {
//println 'testit'
def obj = repository.findByLastName("Vinodh");
ObjectMapper myObjectMapper = new ObjectMapper();
myObjectMapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
def temp = []
obj.collect{
temp << myObjectMapper.writeValueAsString(it)
}
temp
}
OutPut I get:
[
"{\"id\":\"54fe7bbfd416859826ae53ea\",\"firstName\":\"Priya\",\"lastName\":\"Vinodh\"}",
"{\"id\":\"54fe7be8d416f74f961678fa\",\"firstName\":\"Mrithula\",\"lastName\":\"Vinodh\"}"
]
What should be done to eliminate the "\".