json.txt
majors.txt
java bean
MajorBean.txt
//////------ERROR
com.alibaba.fastjson.JSONException: create instance error, class major.MajorBean$Major
at com.alibaba.fastjson.parser.JavaBeanDeserializ
at com.alibaba.fastjson.parser.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:631)
at com.alibaba.fastjson.parser.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:95)
at com.alibaba.fastjson.parser.ListTypeFieldDeserializer.parseArray(ListTypeFieldDeserializer.java:201)
at com.alibaba.fastjson.parser.ListTypeFieldDeserializer.parseField(ListTypeFieldDeserializer.java:63)
at com.alibaba.fastjson.parser.JavaBeanDeserializer.parseField(JavaBeanDeserializer.java:874)
at com.alibaba.fastjson.parser.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:695)
at com.alibaba.fastjson.parser.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:95)
at com.alibaba.fastjson.parser.ListTypeFieldDeserializer.parseArray(ListTypeFieldDeserializer.java:201)
at com.alibaba.fastjson.parser.ListTypeFieldDeserializer.parseField(ListTypeFieldDeserializer.java:63)
at com.alibaba.fastjson.parser.JavaBeanDeserializer.parseField(JavaBeanDeserializer.java:874)
at com.alibaba.fastjson.parser.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:695)
at com.alibaba.fastjson.parser.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:95)
at com.alibaba.fastjson.parser.DefaultJSONParser.parseArray(DefaultJSONParser.java:761)
at com.alibaba.fastjson.parser.DefaultJSONParser.parseArray(DefaultJSONParser.java:699)
at com.alibaba.fastjson.parser.DefaultJSONParser.parseArray(DefaultJSONParser.java:694)
at com.alibaba.fastjson.JSON.parseArray(JSON.java:306)
at cn.addapp.androidpickers.MainActivity.onAddress2Picker(MainActivity.java:411)
at java.lang.reflect.Method.invoke(Native Method)
at android.view.View$DeclaredOnClickListener.onClick(View.java:4456)
at android.view.View.performClick(View.java:5207)
at android.view.View$PerformClick.run(View.java:21177)
at android.os.Handler.handleCallback(Handler.java:742)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:5524)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
Caused by: java.lang.IllegalArgumentException: method major.MajorBean$Major. argument 1 has type major.MajorBean, got major.MajorBean$MajorCategory
at java.lang.reflect.Constructor.newInstance(Native Method)
at com.alibaba.fastjson.parser.JavaBeanDeserializer.createInstance(JavaBeanDeserializer.java:76)
at com.alibaba.fastjson.parser.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:631)
at com.alibaba.fastjson.parser.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:95)
at com.alibaba.fastjson.parser.ListTypeFieldDeserializer.parseArray(ListTypeFieldDeserializer.java:201)
at com.alibaba.fastjson.parser.ListTypeFieldDeserializer.parseField(ListTypeFieldDeserializer.java:63)
at com.alibaba.fastjson.parser.JavaBeanDeserializer.parseField(JavaBeanDeserializer.java:874)
at com.alibaba.fastjson.parser.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:695)
at com.alibaba.fastjson.parser.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:95)
at com.alibaba.fastjson.parser.ListTypeFieldDeserializer.parseArray(ListTypeFieldDeserializer.java:201)
at com.alibaba.fastjson.parser.ListTypeFieldDeserializer.parseField(ListTypeFieldDeserializer.java:63)
at com.alibaba.fastjson.parser.JavaBeanDeserializer.parseField(JavaBeanDeserializer.java:874)
at com.alibaba.fastjson.parser.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:695)
at com.alibaba.fastjson.parser.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:95)
at com.alibaba.fastjson.parser.DefaultJSONParser.parseArray(DefaultJSONParser.java:761)
at com.alibaba.fastjson.parser.DefaultJSONParser.parseArray(DefaultJSONParser.java:699)
at com.alibaba.fastjson.parser.DefaultJSONParser.parseArray(DefaultJSONParser.java:694)
at com.alibaba.fastjson.JSON.parseArray(JSON.java:306)
at cn.addapp.androidpickers.MainActivity.onAddress2Picker(MainActivity.java:411)
at java.lang.reflect.Method.invoke(Native Method)
//--------------------
List majorBean = JSON.parseArray(json, MajorBean.class);
fastjson version: 'com.alibaba:fastjson:1.1.56.android'
but gson works fine
暂无答案!
目前还没有任何答案,快来回答吧!