View Full Version : Json with html content

7 Apr 2011, 7:02 PM
Hi everyone,

I have a form and load data to it form from database. I used form.load()... and everything just fine. However when I load HTML content to JSON in form.load() and pass data into htmleditor, it shows that json is not valid format. I understand that JSON can not contain " and / but do not know how to encode it in java for htmleditor to load data in a correct format.


8 Apr 2011, 8:18 AM
Here's a block of properly formatted JSON that a test form loads successfully, where the 'newsItem' field populates an HtmlEditor component:

"title":"Scheduled Quantity Issues",
"newsItem":"Several departments have reported<font color=\"#ff0000\"> incorrect Scheduled Quantity values </font>being entered on recent Manufacturing Orders.&nbsp; Please read the <a href=\"http://someHostName/mfgOrderGuidelines.html\" target=\"_blank\">Guidelines for Creating Mfg. Orders</a> to clear up any confusion.&nbsp; <br><br>Sincerely,<br><br><b>The Management.</b><br>",
In my case, the backend is coded in Java, so the encoding/formatting is handled transparently by the Spring Framework's JSON view (backed by the Jackson JSON Mapper).

Hope the data example helps.