GSON not deserializing object correctly

时间:2015-06-25 18:54:15

标签: java serialization gson

I have a simple object that I am serializing on and iOS device, sending to an Android device, and deserializing on the Android device. The object has 3 fields an enum and 2 integers. Here is the serialized form of the object on the iOS device: data = {"mTurnTimer":60,"mCreoCount":1,"mStage":"DRY_GRASS"} I also see the above on the Android device as a string, but when I call serializedOptions = json.fromJson(data, BattleOptions.class) and print out the fields, I see the default values that are set in the constructor. I also went ahead and serialized the deserialized object just to see the output and this is what I saw: json.toJson(serializedOptions)) -> {"bvu":"OCEAN","bvv":3,"bvw":120} So this does not make any sense to me, since the String that is being received is structured correctly, but the output is incorrect. Any suggestions on how to correct this?

0 个答案:

没有答案