json
This commit is contained in:
@@ -35,9 +35,9 @@ public final class EnMember<W extends Writer, T, F> {
|
|||||||
// final boolean isnumber;
|
// final boolean isnumber;
|
||||||
final boolean bool;
|
final boolean bool;
|
||||||
|
|
||||||
final char[] jsonFieldNameChars;
|
final char[] jsonFieldNameColonChars;
|
||||||
|
|
||||||
final byte[] jsonFieldNameBytes;
|
final byte[] jsonFieldNameColonBytes;
|
||||||
|
|
||||||
// 对应类成员的Field也可能为null
|
// 对应类成员的Field也可能为null
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -68,8 +68,8 @@ public final class EnMember<W extends Writer, T, F> {
|
|||||||
Class t = attribute.type();
|
Class t = attribute.type();
|
||||||
this.string = CharSequence.class.isAssignableFrom(t);
|
this.string = CharSequence.class.isAssignableFrom(t);
|
||||||
this.bool = t == Boolean.class || t == boolean.class;
|
this.bool = t == Boolean.class || t == boolean.class;
|
||||||
this.jsonFieldNameChars = ('"' + attribute.field() + "\":").toCharArray();
|
this.jsonFieldNameColonChars = ('"' + attribute.field() + "\":").toCharArray();
|
||||||
this.jsonFieldNameBytes = ('"' + attribute.field() + "\":").getBytes();
|
this.jsonFieldNameColonBytes = ('"' + attribute.field() + "\":").getBytes();
|
||||||
this.comment = "";
|
this.comment = "";
|
||||||
this.field = null;
|
this.field = null;
|
||||||
this.method = null;
|
this.method = null;
|
||||||
@@ -86,8 +86,8 @@ public final class EnMember<W extends Writer, T, F> {
|
|||||||
Class t = attribute.type();
|
Class t = attribute.type();
|
||||||
this.string = CharSequence.class.isAssignableFrom(t);
|
this.string = CharSequence.class.isAssignableFrom(t);
|
||||||
this.bool = t == Boolean.class || t == boolean.class;
|
this.bool = t == Boolean.class || t == boolean.class;
|
||||||
this.jsonFieldNameChars = ('"' + attribute.field() + "\":").toCharArray();
|
this.jsonFieldNameColonChars = ('"' + attribute.field() + "\":").toCharArray();
|
||||||
this.jsonFieldNameBytes = ('"' + attribute.field() + "\":").getBytes();
|
this.jsonFieldNameColonBytes = ('"' + attribute.field() + "\":").getBytes();
|
||||||
if (field != null) {
|
if (field != null) {
|
||||||
Comment ct = field.getAnnotation(Comment.class);
|
Comment ct = field.getAnnotation(Comment.class);
|
||||||
this.comment = ct == null ? "" : ct.value();
|
this.comment = ct == null ? "" : ct.value();
|
||||||
@@ -156,12 +156,12 @@ public final class EnMember<W extends Writer, T, F> {
|
|||||||
return comment;
|
return comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public char[] getJsonFieldNameChars() {
|
public char[] getJsonFieldNameColonChars() {
|
||||||
return jsonFieldNameChars;
|
return jsonFieldNameColonChars;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getJsonFieldNameBytes() {
|
public byte[] getJsonFieldNameColonBytes() {
|
||||||
return jsonFieldNameBytes;
|
return jsonFieldNameColonBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Encodeable<W, F> getEncoder() {
|
public Encodeable<W, F> getEncoder() {
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ public class JsonBytesWriter extends JsonWriter implements ByteTuple {
|
|||||||
writeTo(BYTE_COMMA);
|
writeTo(BYTE_COMMA);
|
||||||
}
|
}
|
||||||
if (member != null) {
|
if (member != null) {
|
||||||
byte[] bs = member.getJsonFieldNameBytes();
|
byte[] bs = member.getJsonFieldNameColonBytes();
|
||||||
expand(bs.length);
|
expand(bs.length);
|
||||||
System.arraycopy(bs, 0, content, count, bs.length);
|
System.arraycopy(bs, 0, content, count, bs.length);
|
||||||
count += bs.length;
|
count += bs.length;
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public class JsonCharsWriter extends JsonWriter {
|
|||||||
writeTo(',');
|
writeTo(',');
|
||||||
}
|
}
|
||||||
if (member != null) {
|
if (member != null) {
|
||||||
writeTo(member.getJsonFieldNameChars());
|
writeTo(member.getJsonFieldNameColonChars());
|
||||||
} else {
|
} else {
|
||||||
writeLatin1To(true, fieldName);
|
writeLatin1To(true, fieldName);
|
||||||
writeTo(':');
|
writeTo(':');
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ public abstract class JsonWriter extends Writer {
|
|||||||
writeTo(BYTE_COMMA);
|
writeTo(BYTE_COMMA);
|
||||||
}
|
}
|
||||||
if (member != null) {
|
if (member != null) {
|
||||||
writeTo(member.getJsonFieldNameBytes());
|
writeTo(member.getJsonFieldNameColonBytes());
|
||||||
} else {
|
} else {
|
||||||
writeLatin1To(true, fieldName);
|
writeLatin1To(true, fieldName);
|
||||||
writeTo(BYTE_COLON);
|
writeTo(BYTE_COLON);
|
||||||
|
|||||||
Reference in New Issue
Block a user