Can GSON deserialize in a case-insensitive way

前端 未结 1 1962
一向
一向 2020-12-14 07:36

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 p

相关标签:
1条回答
  • 2020-12-14 08:28

    Use FieldNamingPolicy on a GsonBuilder, to get your Gson object. Yours seems to match UPPER_CAMEL_CASE.

    Gson gson = new GsonBuilder()
            .setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)
            .create();
    

    For any exceptions, annotate your class field with a @SerializedName annotation.

    0 讨论(0)
提交回复
热议问题