fix TSerializer
This commit is contained in:
parent
78a5f6ce4f
commit
11c4436b87
@ -28,14 +28,14 @@ public class TSerializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static TSerializable read(TSerializable serializable, String serializedString) {
|
public static TSerializable read(TSerializable serializable, String serializedString) {
|
||||||
SimpleReflection.checkAndSave(serializable.getClass());
|
|
||||||
try {
|
try {
|
||||||
JsonObject jsonObject = (JsonObject) new JsonParser().parse(serializedString);
|
JsonObject jsonObject = (JsonObject) new JsonParser().parse(serializedString);
|
||||||
if (jsonObject.has("serializeObject")) {
|
if (jsonObject.has("serializeObject")) {
|
||||||
JsonObject serializeObject = jsonObject.getAsJsonObject("serializeObject");
|
JsonObject serializeObject = jsonObject.getAsJsonObject("serializeObject");
|
||||||
for (Map.Entry<String, JsonElement> jsonElementEntry : serializeObject.entrySet()) {
|
for (Map.Entry<String, JsonElement> jsonElementEntry : serializeObject.entrySet()) {
|
||||||
try {
|
try {
|
||||||
Field declaredField = SimpleReflection.getField(serializable.getClass(), jsonElementEntry.getKey());
|
Field declaredField = serializable.getClass().getDeclaredField(jsonElementEntry.getKey());
|
||||||
|
declaredField.setAccessible(true);
|
||||||
if (declaredField.isAnnotationPresent(DoNotSerialize.class)) {
|
if (declaredField.isAnnotationPresent(DoNotSerialize.class)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -100,7 +100,8 @@ public class TSerializer {
|
|||||||
SimpleReflection.checkAndSave(serializable.getClass());
|
SimpleReflection.checkAndSave(serializable.getClass());
|
||||||
JsonObject jsonObject = new JsonObject();
|
JsonObject jsonObject = new JsonObject();
|
||||||
JsonObject serializeObject = new JsonObject();
|
JsonObject serializeObject = new JsonObject();
|
||||||
for (Field declaredField : SimpleReflection.getFields(serializable.getClass()).values()) {
|
for (Field declaredField : serializable.getClass().getDeclaredFields()) {
|
||||||
|
declaredField.setAccessible(true);
|
||||||
try {
|
try {
|
||||||
if (!declaredField.isAnnotationPresent(DoNotSerialize.class) && !Modifier.isStatic(declaredField.getModifiers())) {
|
if (!declaredField.isAnnotationPresent(DoNotSerialize.class) && !Modifier.isStatic(declaredField.getModifiers())) {
|
||||||
Object fieldObject = declaredField.get(serializable);
|
Object fieldObject = declaredField.get(serializable);
|
||||||
|
Loading…
Reference in New Issue
Block a user