From ae6200f36d2a4e46d3762c480e221e4ad09754ce Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 6 Apr 2023 12:07:28 +0100 Subject: [PATCH] JSON encoding - Enums which override toString Using toString in the encoder and Enum.valueOf is not reversible if an enum overrides toString. name and valueOf are the correct inverse functions. --- .../java/org/nustaq/serialization/coders/FSTJsonEncoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/nustaq/serialization/coders/FSTJsonEncoder.java b/src/main/java/org/nustaq/serialization/coders/FSTJsonEncoder.java index 49f92298..d73bc16b 100644 --- a/src/main/java/org/nustaq/serialization/coders/FSTJsonEncoder.java +++ b/src/main/java/org/nustaq/serialization/coders/FSTJsonEncoder.java @@ -326,7 +326,7 @@ public boolean writeTag(byte tag, Object infoOrObject, long somValue, Object toW gen.writeFieldName(fieldNames.ENUM_S); writeSymbolicClazz(null,c); gen.writeFieldName(fieldNames.VAL_S); - gen.writeString(toWrite.toString()); + gen.writeString(((Enum)toWrite).name()); gen.writeEndObject(); return true; default: