This commit is contained in:
redkale
2024-10-23 09:43:03 +08:00
parent 3a7a462f65
commit 95e207fd34
2 changed files with 5 additions and 5 deletions

View File

@@ -374,7 +374,7 @@ public class ObjectDecoder<R extends Reader, T> implements Decodeable<R, T> {
DeMemberInfo info = this.memberInfo; DeMemberInfo info = this.memberInfo;
if (this.creatorConstructorMembers == null) { // 空构造函数 if (this.creatorConstructorMembers == null) { // 空构造函数
final T result = this.creator == null ? null : this.creator.create(); final T result = this.creator == null ? null : this.creator.create();
while (in.hasNext()) { do {
DeMember member = in.readField(info); DeMember member = in.readField(info);
in.readColon(); in.readColon();
if (member == null) { if (member == null) {
@@ -383,7 +383,7 @@ public class ObjectDecoder<R extends Reader, T> implements Decodeable<R, T> {
Object val = readDeMemberValue(in, member); Object val = readDeMemberValue(in, member);
member.getAttribute().set(result, val); member.getAttribute().set(result, val);
} }
} } while (in.hasNext());
in.readObjectE(typeClass); in.readObjectE(typeClass);
return result; return result;
} else { // 带参数的构造函数 } else { // 带参数的构造函数
@@ -391,7 +391,7 @@ public class ObjectDecoder<R extends Reader, T> implements Decodeable<R, T> {
final Object[] constructorParams = new Object[constructorFields.length]; final Object[] constructorParams = new Object[constructorFields.length];
final Object[][] otherParams = new Object[info.length()][2]; final Object[][] otherParams = new Object[info.length()][2];
int oc = 0; int oc = 0;
while (in.hasNext()) { do { // in.hasNext()放在下面因readObjectB已经读了{
DeMember member = in.readField(info); DeMember member = in.readField(info);
in.readColon(); in.readColon();
if (member == null) { if (member == null) {
@@ -410,7 +410,7 @@ public class ObjectDecoder<R extends Reader, T> implements Decodeable<R, T> {
otherParams[oc++] = new Object[] {member.attribute, val}; otherParams[oc++] = new Object[] {member.attribute, val};
} }
} }
} } while (in.hasNext());
in.readObjectE(typeClass); in.readObjectE(typeClass);
if (this.creator == null) { if (this.creator == null) {
return null; return null;

View File

@@ -184,7 +184,7 @@ public class JsonConvert extends TextConvert<JsonReader, JsonWriter> {
if (text == null) { if (text == null) {
return null; return null;
} }
return convertFrom(type, Utility.charArray(text)); return convertFrom(type, new JsonReader(text));
} }
public <T> T convertFrom(final Type type, final char[] text) { public <T> T convertFrom(final Type type, final char[] text) {