Home > database >  Do capital letters in variables make a difference in Serialization?
Do capital letters in variables make a difference in Serialization?

Time:01-12

I've discovered (the hard way) that variables with all capital letters in my Android Java code, are not being serialized to bytes and sent via Rest Api to my Java backend server.

When both client and server use **ABC** as the variable name, the server receives a null value for this variable.

When both client and server use **abc** as the variable in lower case, then it serializes correctly, and the server receives the correct response.

Why is this the case, because if I was using Final values, then they would have been in capitals anyway?

The variable was this:

List<Object> OBJ;

Does it matter if the variable was a List?

CodePudding user response:

You can use GSON for serialisation and provide the name of variable that is expected by the api in the @SerializedName("api_name") and keep the actual name of variable any way you want.

  •  Tags:  
  • Related