I am using ck editor at UI side to send some text to backend in html format(as a string). In this process I am using a JSON that will carry all the necessary key values to service. From UI it the post will carry following data:
{
"payload": {
"title": "Some title",
"categoryId": 64,
"richContent": "<p>\n\this is the content that need to be stored in the database</p>\n",
"goLiveOn": 1388219580000,
"id": 150
}
}
when it reaches the service method I am retrieving the JSON object like this:
@POST
@RestService(input = Article.class, output = Boolean.class)
@ServiceStatus(value = "complete")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/save")
public String save(@Context HttpHeaders headers, @Context UriInfo uriInfo,
WebserviceRequest request) throws Exception {
Article article = (Article) JsonUtil.getObject(request.getPayload(),
Article.class);
Boolean saveStatus = ArticleHandler.getInstance().save(article);
return JsonUtil.getJsonBasedOnDescriptor(saveStatus,
Boolean.class);
}
but when this object is reaching the save mthod in handler the richContent is changed to
<p>this is the content that need to be stored in the database</p>
code for getObject method is as follows:
public static Object getObject(Object source, Class targetType) {
try {
return objMapper.convertValue(source, targetType);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
but I need it in the same format as it was earlier so that i can perform few more operation on the same before saving it to db. Any help will be appreciated. Thank you in advance.
....
before saving it to db – kavinder Dec 20 '13 at 09:45