This commit is contained in:
redkale
2024-10-17 19:55:40 +08:00
parent cc760ff327
commit 1491f6be70
4 changed files with 13 additions and 13 deletions

View File

@@ -35,9 +35,9 @@ public final class EnMember<W extends Writer, T, F> {
// final boolean isnumber;
final boolean bool;
final char[] jsonFieldNameChars;
final char[] jsonFieldNameColonChars;
final byte[] jsonFieldNameBytes;
final byte[] jsonFieldNameColonBytes;
// 对应类成员的Field也可能为null
@Nullable
@@ -68,8 +68,8 @@ public final class EnMember<W extends Writer, T, F> {
Class t = attribute.type();
this.string = CharSequence.class.isAssignableFrom(t);
this.bool = t == Boolean.class || t == boolean.class;
this.jsonFieldNameChars = ('"' + attribute.field() + "\":").toCharArray();
this.jsonFieldNameBytes = ('"' + attribute.field() + "\":").getBytes();
this.jsonFieldNameColonChars = ('"' + attribute.field() + "\":").toCharArray();
this.jsonFieldNameColonBytes = ('"' + attribute.field() + "\":").getBytes();
this.comment = "";
this.field = null;
this.method = null;
@@ -86,8 +86,8 @@ public final class EnMember<W extends Writer, T, F> {
Class t = attribute.type();
this.string = CharSequence.class.isAssignableFrom(t);
this.bool = t == Boolean.class || t == boolean.class;
this.jsonFieldNameChars = ('"' + attribute.field() + "\":").toCharArray();
this.jsonFieldNameBytes = ('"' + attribute.field() + "\":").getBytes();
this.jsonFieldNameColonChars = ('"' + attribute.field() + "\":").toCharArray();
this.jsonFieldNameColonBytes = ('"' + attribute.field() + "\":").getBytes();
if (field != null) {
Comment ct = field.getAnnotation(Comment.class);
this.comment = ct == null ? "" : ct.value();
@@ -156,12 +156,12 @@ public final class EnMember<W extends Writer, T, F> {
return comment;
}
public char[] getJsonFieldNameChars() {
return jsonFieldNameChars;
public char[] getJsonFieldNameColonChars() {
return jsonFieldNameColonChars;
}
public byte[] getJsonFieldNameBytes() {
return jsonFieldNameBytes;
public byte[] getJsonFieldNameColonBytes() {
return jsonFieldNameColonBytes;
}
public Encodeable<W, F> getEncoder() {

View File

@@ -119,7 +119,7 @@ public class JsonBytesWriter extends JsonWriter implements ByteTuple {
writeTo(BYTE_COMMA);
}
if (member != null) {
byte[] bs = member.getJsonFieldNameBytes();
byte[] bs = member.getJsonFieldNameColonBytes();
expand(bs.length);
System.arraycopy(bs, 0, content, count, bs.length);
count += bs.length;

View File

@@ -121,7 +121,7 @@ public class JsonCharsWriter extends JsonWriter {
writeTo(',');
}
if (member != null) {
writeTo(member.getJsonFieldNameChars());
writeTo(member.getJsonFieldNameColonChars());
} else {
writeLatin1To(true, fieldName);
writeTo(':');

View File

@@ -254,7 +254,7 @@ public abstract class JsonWriter extends Writer {
writeTo(BYTE_COMMA);
}
if (member != null) {
writeTo(member.getJsonFieldNameBytes());
writeTo(member.getJsonFieldNameColonBytes());
} else {
writeLatin1To(true, fieldName);
writeTo(BYTE_COLON);