json
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -121,7 +121,7 @@ public class JsonCharsWriter extends JsonWriter {
|
||||
writeTo(',');
|
||||
}
|
||||
if (member != null) {
|
||||
writeTo(member.getJsonFieldNameChars());
|
||||
writeTo(member.getJsonFieldNameColonChars());
|
||||
} else {
|
||||
writeLatin1To(true, fieldName);
|
||||
writeTo(':');
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user