Skip to content

Commit cfb5853

Browse files
committed
bug fix
1 parent 5f6e644 commit cfb5853

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

core/src/main/java/com/alibaba/fastjson2/writer/ObjectWriterCreator.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ protected static String getFieldName(
503503
}
504504

505505
if ((len == 1 && c0 >= 'a' && c0 <= 'z')
506-
|| (len > 2 && c0 >= 'A' && c0 <= 'Z' && (c1 = fieldName.charAt(1)) >= 'A' && c1 <= 'Z')
506+
|| (len > 1 && c0 >= 'A' && c0 <= 'Z' && (c1 = fieldName.charAt(1)) >= 'A' && c1 <= 'Z')
507507
) {
508508
char[] chars = fieldName.toCharArray();
509509
if (c0 >= 'a' && c0 <= 'z') {
@@ -514,8 +514,18 @@ protected static String getFieldName(
514514
String fieldName1 = new String(chars);
515515
Field field = BeanUtils.getDeclaredField(objectClass, fieldName1);
516516

517-
if (field != null && (len == 1 || Modifier.isPublic(field.getModifiers()))) {
518-
fieldName = field.getName();
517+
if (field != null) {
518+
boolean ucaseAll = true;
519+
for (int i = 2; i < chars.length; i++) {
520+
char c = chars[i];
521+
if (c >= 'a' && c <= 'z') {
522+
ucaseAll = false;
523+
break;
524+
}
525+
}
526+
if (ucaseAll || Modifier.isPublic(field.getModifiers())) {
527+
fieldName = fieldName1;
528+
}
519529
}
520530
}
521531
} else {

core/src/main/java/com/alibaba/fastjson2/writer/ObjectWriterImplInt8ValueArray.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ public void write(JSONWriter jsonWriter, Object object, Object fieldName, Type f
6767

6868
if ((features & JSONWriter.Feature.WriteNonStringValueAsString.mask) != 0) {
6969
jsonWriter.writeString(bytes);
70-
} else if ("gzip".equals(format) || "gzip,base64".equals(format)) {
70+
return;
71+
}
72+
73+
if ("gzip".equals(format) || "gzip,base64".equals(format)) {
7174
GZIPOutputStream gzipOut = null;
7275
try {
7376
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();

0 commit comments

Comments
 (0)