New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSONCreator 参数不匹配导致反序列化失败 #802
Comments
在JavaBeanDeserializer类的deserialze方法中,其中以下代码: FieldInfo[] fieldInfoList = beanInfo.fields;
int size = fieldInfoList.length;
Object[] params = new Object[size];
for (int i = 0; i < size; ++i) {
FieldInfo fieldInfo = fieldInfoList[i];
params[i] = fieldValues.get(fieldInfo.name);
}
if (beanInfo.creatorConstructor != null) {
try {
object = beanInfo.creatorConstructor.newInstance(params);
} catch (Exception e) {
throw new JSONException("create instance error, "
+ beanInfo.creatorConstructor.toGenericString(), e);
}
} else if (beanInfo.factoryMethod != null) {
try {
object = beanInfo.factoryMethod.invoke(null, params);
} catch (Exception e) {
throw new JSONException("create factory method error, " + beanInfo.factoryMethod.toString(), e);
}
} 这里的params用于作为构造方法中的参数传入,它的值是根据前面的 |
问题解决,请等待1.2.17发布吧 |
@wenshao 您好,请问这个问题的修复包含在了android版本了吗? |
I need this fix to be included in android version. |
This was referenced Apr 23, 2017
wenshao
added a commit
that referenced
this issue
Apr 23, 2017
wenshao
added a commit
that referenced
this issue
Jul 17, 2019
asa1997
pushed a commit
to Be-Secure/fastjson
that referenced
this issue
Feb 8, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
服务端返回的JSON当中,有些字段没有返回,导致反序列化失败。以下是构造方法:
其中
location_id
和park_code
没有传时会报异常:另外,还发现,如果缺少的字段为String时能够正常创建实例,而在上面的例子中为int时创建实例失败。
The text was updated successfully, but these errors were encountered: