I have a list which contains Objects of OClass . I want to create the JSON of this Objects . Here's my code:
public void getClasss() {
// returns all the top classes present in the ontology.
classlist = new ArrayList<OClass>();
Set<OClass> topclasses = ontology.getOClasses(true);
for (OClass oClasses : topclasses) {
classlist.add(oClasses);
}
OntoCreationClass ocreat = new OntoCreationClass();
ocreat.OntoCreation(classlist);
}
public class OntoCreationClass {
public static String data;
public void OntoCreation(List<OClass> list) {
System.out.println(list.get(0));
OutputStream out = new ByteArrayOutputStream();
ObjectMapper mapper = new ObjectMapper();
try {
mapper.writeValue(out, list);
} catch (JsonGenerationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Exception is :
com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class com.ontotext.trree.owlim_ext.r and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: java.util.ArrayList[0]->gate.creole.ontology.impl.OClassImpl["ontology"]-gate.creole.ontology.impl.sesame.OWLIMOntology["service"]-gate.creole.ontology.impl.sesame.OntologyServiceImplSesame["sesameManager"]-gate.creole.ontology.impl.sesame.SesameManager["repositoryConnection"]-org.openrdf.repository.sail.SailRepositoryConnection["repository"]-org
.openrdf.repository.sail.SailRepository["sail"]-com.ontotext.trree.owlim_ext.SailImpl["pool"])>
How can i solve this error ? can anyone help ?