Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: how to get json from structures liferay 7.4
I have a question for you, i don't understand why in this newest
version of liferay there is no section of "code for the
structure" for get the json.
On liferay from 6.x to 7.3
there were this section. There are some settings to do for this ?
Thanks,
Gianluca.
Charalampos Chrysikopoulos, modified 2 Years ago.
Junior Member
Posts: 79
Join Date: 12/9/11
Recent Posts
Hi Gianluca,
you could try using the following code:
@Reference
private com.liferay.dynamic.data.mapping.io.DDMFormSerializer ddmFormSerializer;
...
private void getStructureJson(long groupId) {
List<DDMStructure> structures = DDMStructureLocalServiceUtil.getStructures(groupId);
for (DDMStructure structure : structures) {
_log.info("STRUCTURE KEY:" + structure.getStructureKey());
DDMFormSerializerSerializeRequest.Builder builder = DDMFormSerializerSerializeRequest.Builder.newBuilder(structure.getDDMForm());
DDMFormSerializerSerializeResponse ddmFormSerializerSerializeResponse = ddmFormSerializer.serialize(builder.build());
String json = ddmFormSerializerSerializeResponse.getContent();
_log.info(" JSON:" + json);
}
}