First explain the reason:json this thing is not smart enough, in parsing JavaBean object getter and setter method, will be two methods named very similar method as one. thus forming an anomaly.
Workaround: Rename the method name.
It is also important to note that JSON writes a meta objectthat is associated with it when it is written to it (not necessarily a reset, probably just a traversal).
Here is our JSON write exception:
Com.cutt.zhiyue.android.api.io.exception.JsonFormaterException: Com.fasterxml.jackson.databind.JsonMappingException:Conflicting getter definitions for property "groupwanted": com.cutt.zhiyue.android.model.meta.order.orderproductmeta#isgroupwanted (0 params) vs com.cutt.zhiyue.android.model.meta.order.orderproductmeta#getgroupwanted (0 params) (through reference chain: com.cutt.zhiyue.android.model.meta.card.cardmetaatom["article"]-> com.cutt.zhiyue.android.model.meta.article.article["creator"]-> com.cutt.zhiyue.android.api.model.meta.userinfo["Product"]->java.util.arraylist[0])
Part of the code that caused the exception:
1 Public intgetgroupwanted () {2 returngroupwanted;3 }4 5 Public voidSetgroupwanted (intgroupwanted) {6 This. groupwanted =groupwanted;7 }8 9 Public Booleanisgroupwanted () {Ten returngroupwanted = = 1; One}
getgroupwanted () and isgroupwanted () are they like?
Found:
Today's test made a bug: a page to jump to page B, on page B jump to C page, c page back to page B, b page directly destroyed, and returned to page A.
After debug found: The OnCreate () method in page B is:
1 Super . OnCreate (savedinstancestate); 2 if NULL ) {3 Notice (r.string.error_article_data); 4 return ; 5 }
Which causes the B page to be destroyed directly, is this curatom== null. Visible Curatom This variable must be initialized in the parent class. We jump to the parent class to see what we found in the OnCreate () method:
Makeatom (savedinstancestate,intent);
1 Private voidMakeatom (Bundle savedinstancestate, Intent Intent) {2 if(Savedinstancestate! =NULL) {3String atom =savedinstancestate.getstring (boundle_atom);4 Try {5Curatom = Jsonparser.getvalue (Jsonobjectmapper.getobjectmapper (), Atom, Cardmetaatom.class);6}Catch(dataparserexception e) {7 e.printstacktrace ();8Curatom =Articleactivityfactory.getinputatom (intent);9 }Ten}Else { OneCuratom =Articleactivityfactory.getinputatom (intent); A } -}
This method is very simple, I will not explain. Debug found Savedinstancestate Although not empty, but from the inside of the value is not taken. Then we need to see why it is not worth the value, is not stored at all.
Then came the Onsaveinstancestate () method.
1 @Override2 protected voidonsaveinstancestate (Bundle outstate) {3 Try {4String atom =Jsonwriter.writevalue (curatom);5 outstate.putstring (Boundle_atom, ATOM);6}Catch(jsonformaterexception e) {7 e.printstacktrace ();8 }9 Super. Onsaveinstancestate (outstate);Ten}
or after debug found Curatom this variable is not written at all, because the article begins with the JSON exception reported.
Meta Object writes JSON error: com.cutt.zhiyue.android.api.io.exception.JsonFormaterException: Com.fasterxml.jackson.databind.JsonMappingException