In prototyping communication between .NET desktop app and Java server, using REST with JSON posts, I am running into a case-sensitivity issue. The .NET objects have there properties in Pascal Casing (which is conventional for .NET), e.g.: Symbol, EntryValue (etc), while the Java representation of same object uses camel casing, e.g. symbol, entryValue.
The server receives json value as:
{"EntrySize":100,"Symbol":"AMZN"}
But Gson doesn’t deserialize in case-insensitive manner. Is there any way to get Gson to do this?
Use
FieldNamingPolicyon aGsonBuilder, to get yourGsonobject. Yours seems to matchUPPER_CAMEL_CASE.For any exceptions, annotate your class field with a
@SerializedNameannotation.