0

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

&lt;p&gt;this is the content that need to be stored in the database&lt;/p&gt;

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.

kavinder
  • 609
  • 1
  • 5
  • 13
  • Have you tried the use of `.replaceAll()` ? – Reporter Dec 20 '13 at 09:39
  • http://stackoverflow.com/a/994339/2006839 – Lakshmi Dec 20 '13 at 09:40
  • To check where the cause lies, intercept the JSON data sent. Many tools: for instance in Firefox the TamperData plugin. – Joop Eggen Dec 20 '13 at 09:41
  • @reporter that am supposed to do later on when i get the data in form of

    ....

    before saving it to db
    – kavinder Dec 20 '13 at 09:45
  • and when the control reaches the service method it is getting the required format only but when it reaches the save method then I am finding it in this form <p>this is the content that need to be stored in the database</p> – kavinder Dec 20 '13 at 09:47

0 Answers0