google / google/gson

Change Return type of FieldNamingStrategy.translateName from String to List<String> for alternate. Ex. case insensitive.

Open
#1,002 0 comments 3 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
24.2k
Forks
4.5k
Avg merge
6d 4h
Merged PRs (30d)
12

Description

To serialize/Deserialize case insensitive fieldnames,

I use annotation SerializedName like..

`@SerializedName(value="fieldName",alternate={"fieldname","FIELDNAME"})`

But too many @SerializedName .... I don't wanna check typo any more.

Just all i want is to case insensitive FieldNamingPolicy.. but.. no implementations..

So, reviewed some gson source, and I found ReflectiveTypeAdapterFactory is adding alternate...

but by FieldNamingStragy, just one fieldname is added to BoundField.

If FieldNamingStrategy.translateName returns List, and TypeAdapterFactory support it.

I can add case insensitive FieldNamePolicy for my own. :)

Or how about add case insensitive options?

Case insensitive fieldname policy is bad ideas? :(

Some json parser has restricted naming policy, i'ts hard to make multiple language RESTful API SDK.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.