Facing issue with Exporter while exporting with JSONObject on page getting unwanted format
Facing issue with Exporter while exporting with JSONObject on page getting unwanted format like
Getting :
"options" : {
"id-option-1" : {
"altText" : {
"chars" : "default:asset:description",
"string" : "default:asset:description",
"valueType" : "STRING"
},
"description" : {
"chars" : "\u003Cp\u003ESample Descritption\u003C/p\u003E",
"string" : "\u003Cp\u003ESample Descritption\u003C/p\u003E",
"valueType" : "STRING"
}
},
"id-option-2" : {
"altText" : {
"chars" : "default:asset:description",
"string" : "default:asset:description",
"valueType" : "STRING"
},
"description" : {
"chars" : "\u003Cp\u003Esample description 2\u003C/p\u003E",
"string" : "\u003Cp\u003Esample description 2\u003C/p\u003E",
"valueType" : "STRING"
}
},required format:
options: {
'id-option-1': {
description: 'Some description 2',
buttonText: 'This is the option 1 text',
},
'id-option-2': {
description: 'Some description 2',
buttonText: 'The is the option 2 text',
},
'id-option-3': {
description: 'Some description 3',
buttonText: 'This is the option 3 text',
},
'id-option-4': {
description: 'Some description 4',
buttonText: 'This is the option 4 text',
},
'id-option-5': {
description: 'Some description 5',
buttonText: 'This is the option 5 text',
},
'id-option-6': {
description: 'Some description 6',
buttonText: 'This is the option 6 text',
},
'id-option-7': {
description: 'Some description 7',
buttonText: 'This is the option 7 text',
},
'id-option-8': {
description: 'Some description 8',
buttonText: 'This is the option 8 text',
},
},
JAVA method in Exporter:
public JsonObject getOptions() {
JsonObjectBuilder jsonkey = Json.createObjectBuilder();
int i = 1;
for (Resource resource: content) {
TreeModel resourceValues = resource.adaptTo(TreeModel.class);
JsonObjectBuilder keynewsArticleJSON = Json.createObjectBuilder();
//keynewsArticleJSON.add("fileReference", (String) resourceValues.getFileReference());
keynewsArticleJSON.add("altText", (String) resourceValues.getAltText());
keynewsArticleJSON.add("description", (String) resourceValues.getDescription().toString());
log.info("filesResference:::::::::::" + resourceValues.getFileReference());
jsonkey.add("id-option-" + i, keynewsArticleJSON.build());
i++;
}
log.info("jsonSsdtring::::::::::::::" + jsonkey.build());
String jsonString = jsonkey.build().toString();
JsonReader jsonReader = Json.createReader(new StringReader(jsonString));
JsonObject object = jsonReader.readObject();
return object;
}
