java - Jackson doesn't deserialize -
i struggling deserializing jackson fasterxml. guess there type information , polymorphic use. tried different things after reading jackson docs , this still not manage it. serialization goes deserializing produced string not make it.
thanks in advance help
here classes :
@jsontypeinfo(use = jsontypeinfo.id.class, include = jsontypeinfo.as.property, property = "@class") private class dynreachslotinternalrep { @jsontypeinfo(use = jsontypeinfo.id.class, include = jsontypeinfo.as.property, property = "@class") private class liststartstop extends mergeablelinkedlist<dyntimeslot> { private static final long serialversionuid = 1l; } private liststartstop[] weekrep = new liststartstop[7]; @suppresswarnings("unused") public liststartstop[] getweekrep() { return weekrep; } @suppresswarnings("unused") public void setweekrep(liststartstop[] weekrep) { this.weekrep = weekrep; } public dynreachslotinternalrep() { super(); } /... @jsontypeinfo(use = jsontypeinfo.id.class, include = jsontypeinfo.as.property, property = "@class") public class dyntimeslot extends intervalcomparison<dyntimeslot> { private int starthour; private int startminute; private int stophour; private int stopminute; public int getstarthour() { return starthour; } public void setstarthour(int starthour) { this.starthour = starthour; } public int getstartminute() { return startminute; } public void setstartminute(int startminute) { this.startminute = startminute; } public int getstophour() { return stophour; } public void setstophour(int stophour) { this.stophour = stophour; } public int getstopminute() { return stopminute; } public void setstopminute(int stopminute) { this.stopminute = stopminute; } public dyntimeslot(int starthour, int startminute, int stophour, int stopminute) { super(); if ((stophour < starthour) || ((stophour == starthour) && (startminute > stopminute))) throw new runtimeexception("malformed timeslot"); this.starthour = starthour; this.startminute = startminute; this.stophour = stophour; this.stopminute = stopminute; } public dyntimeslot() { super(); } /... @jsontypeinfo(use=jsontypeinfo.id.class, include=jsontypeinfo.as.property, property="@class") public class mergeablelinkedlist<a extends intervalcomparison<a>> extends linkedlist<a> { /** * */ private static final long serialversionuid = 1l; public mergeablelinkedlist() { super(); } public void insert(a toinsert) { recursiveinsert(toinsert, this.listiterator()); } public void delete (a todelete) { recursivedelete(todelete, this.listiterator()); }
here stack trace :
com.fasterxml.jackson.databind.jsonmappingexception: no suitable constructor found type [simple type, class com.dynamease.entity.dynreachslot$dynreachslotinternalrep]: can not instantiate json object (need add/enable type information?) @ [source: java.io.stringreader@277b65b1; line: 1, column: 70] @ com.fasterxml.jackson.databind.jsonmappingexception.from(jsonmappingexception.java:164) @ com.fasterxml.jackson.databind.deser.beandeserializerbase.deserializefromobjectusingnondefault(beandeserializerbase.java:984) @ com.fasterxml.jackson.databind.deser.beandeserializer.deserializefromobject(beandeserializer.java:276) @ com.fasterxml.jackson.databind.deser.beandeserializer._deserializeother(beandeserializer.java:157) @ com.fasterxml.jackson.databind.deser.beandeserializer.deserialize(beandeserializer.java:123) @ com.fasterxml.jackson.databind.jsontype.impl.aspropertytypedeserializer._deserializetypedforid(aspropertytypedeserializer.java:113) @ com.fasterxml.jackson.databind.jsontype.impl.aspropertytypedeserializer.deserializetypedfromobject(aspropertytypedeserializer.java:82) @ com.fasterxml.jackson.databind.deser.beandeserializerbase.deserializewithtype(beandeserializerbase.java:894) @ com.fasterxml.jackson.databind.deser.impl.typewrappeddeserializer.deserialize(typewrappeddeserializer.java:36) @ com.fasterxml.jackson.databind.objectmapper._readmapandclose(objectmapper.java:2888) @ com.fasterxml.jackson.databind.objectmapper.readvalue(objectmapper.java:2034) @ com.dynamease.entity.dynreachslot$dyntimeslotoperations.getfromdirectoryrepresentation(dynreachslot.java:145) @ com.dynamease.entity.dynreachslot.<init>(dynreachslot.java:53) @ com.dynamease.entity.dynreachslottest.test2(dynreachslottest.java:31) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:606) @ org.junit.runners.model.frameworkmethod$1.runreflectivecall(frameworkmethod.java:47) @ org.junit.internal.runners.model.reflectivecallable.run(reflectivecallable.java:12) @ org.junit.runners.model.frameworkmethod.invokeexplosively(frameworkmethod.java:44) @ org.junit.internal.runners.statements.invokemethod.evaluate(invokemethod.java:17) @ org.junit.runners.parentrunner.runleaf(parentrunner.java:271) @ org.junit.runners.blockjunit4classrunner.runchild(blockjunit4classrunner.java:70) @ org.junit.runners.blockjunit4classrunner.runchild(blockjunit4classrunner.java:50) @ org.junit.runners.parentrunner$3.run(parentrunner.java:238) @ org.junit.runners.parentrunner$1.schedule(parentrunner.java:63) @ org.junit.runners.parentrunner.runchildren(parentrunner.java:236) @ org.junit.runners.parentrunner.access$000(parentrunner.java:53) @ org.junit.runners.parentrunner$2.evaluate(parentrunner.java:229) @ org.junit.runners.parentrunner.run(parentrunner.java:309) @ org.eclipse.jdt.internal.junit4.runner.junit4testreference.run(junit4testreference.java:50) @ org.eclipse.jdt.internal.junit.runner.testexecution.run(testexecution.java:38) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.runtests(remotetestrunner.java:467) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.runtests(remotetestrunner.java:683) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.run(remotetestrunner.java:390) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.main(remotetestrunner.java:197)
from you've posted, think you're missing jsoncreator() dynreachslotinternalrep
class.
here's nice tutorial.
Comments
Post a Comment