1. Created a custom component dialog, which has field='Answer Text' with richtext field
2. Gave Special characters as input
3. Create Sling Model Exporter for JSON output
@PostConstruct
public void invokepost() {
if (answerText != null && !answerText.isEmpty()) {
answerText = formatAnswerRTEText(answerText);
}
}
// In this method, rteText is passed as a parameter which needs to be trimmed and covered with double quotes and remove all the new lines in the text
private String formatAnswerRTEText(String rteText) {
String modifiedRteText = null;
modifiedRteText = "\"" + rteText.trim() + "\"";
modifiedRteText = modifiedRteText .replaceAll("\\r|\\n", "");
return modifiedRteText ;
}
4. JSON output is not displaying special characters
Please guide me in resolving this issue. (Special characters should be displayed as it is in JSON output)