java - JsonMappingException: Can not instantiate value of type from Integral number; no single-int-arg constructor/factory method -
i'm trying query data have in json tree on firebase. go ahead , create pojo keep getting jsonmappingexception: can not instantiate value of type [simple type, class net.rmoreno.ally.ally] integral number; no single-int-arg constructor/factory method
error. i've made takes consideration string email
keeps crashing , telling me problem integral number. how can fix this.
here code makes crash
query.addchildeventlistener(new childeventlistener() { arraylist<ally> allyarraylist = new arraylist<>(); @override public void onchildadded(datasnapshot datasnapshot, string s) { for(datasnapshot usersnapshot: datasnapshot.getchildren()){ ally information = usersnapshot.getvalue(ally.class); allyarraylist.add(information); } }
here pojo
@jsonignoreproperties({"latitude", "longitude","phone","availability","email"}) public class ally { string name; //string email; //string phone; //int availability; public ally(){ } public string getname(){ return name; } // public string getemail(){ // return email; // } // public string getphone(){ // return phone; // } // public int getavailability(){ // return availability; // } }
here stack track
com.firebase.client.firebaseexception: failed bounce type @ com.firebase.client.datasnapshot.getvalue(datasnapshot.java:185) @ net.rmoreno.ally.mainactivity$1.onchildadded(mainactivity.java:46) @ com.firebase.client.core.childeventregistration.fireevent(childeventregistration.java:58) @ com.firebase.client.core.view.dataevent.fire(dataevent.java:45) @ com.firebase.client.core.view.eventraiser$1.run(eventraiser.java:38) @ android.os.handler.handlecallback(handler.java:739) @ android.os.handler.dispatchmessage(handler.java:95) @ android.os.looper.loop(looper.java:135) @ android.app.activitythread.main(activitythread.java:5221) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:899) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:694) caused by: com.fasterxml.jackson.databind.jsonmappingexception: can not instantiate value of type [simple type, class net.rmoreno.ally.ally] integral number; no single-int-arg constructor/factory method @ com.fasterxml.jackson.databind.deser.std.stdvalueinstantiator.createfromint(stdvalueinstantiator.java:320) @ com.fasterxml.jackson.databind.deser.beandeserializerbase.deserializefromnumber(beandeserializerbase.java:1012) @ com.fasterxml.jackson.databind.deser.beandeserializer._deserializeother(beandeserializer.java:138) @ com.fasterxml.jackson.databind.deser.beandeserializer.deserialize(beandeserializer.java:123) @ com.fasterxml.jackson.databind.objectmapper._readmapandclose(objectmapper.java:2888) @ com.fasterxml.jackson.databind.objectmapper.readvalue(objectmapper.java:2034) @ com.firebase.client.datasnapshot.getvalue(datasnapshot.java:183) at net.rmoreno.ally.mainactivity$1.onchildadded(mainactivity.java:46) at com.firebase.client.core.childeventregistration.fireevent(childeventregistration.java:58) at com.firebase.client.core.view.dataevent.fire(dataevent.java:45) at com.firebase.client.core.view.eventraiser$1.run(eventraiser.java:38) at android.os.handler.handlecallback(handler.java:739) at android.os.handler.dispatchmessage(handler.java:95) at android.os.looper.loop(looper.java:135) at android.app.activitythread.main(activitythread.java:5221) at java.lang.reflect.method.invoke(native method) at java.lang.reflect.method.invoke(method.java:372) at com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:899) at com.android.internal.os.zygoteinit.main(zygoteinit.java:694)
edit: here json structure on firebase
in json have array , rest of fields availability
, email
, name
etc. present inside array.
in ally class trying parse these inner objects directly.
what should doing instead follows:
here inner-object class:
@jsonignoreproperties({"latitude", "longitude","phone","availability","email"}) public class arrayobject { private string name; private string email; private string phone; private int availability; public arrayobject() {} public string getname() { return name; } public string getemail() { return email; } public string getphone() { return phone; } public int getavailability() { return availability; } }
here ally class:
public class ally { private arrayobject arrobj; /* getter-setters */ public ally() {} }
Comments
Post a Comment