codepath / codepath/android_guides

Annotations needed when using Retrofit if attribute names are uppercase

Open
#238 0 comments 0 reactions 0 assignees View on GitHub
needs-update
Dominant language
No language data
Stars
28.3k
Forks
6.2k
PR merge metrics
No merged PRs in 30d

Description

OK, this might not be technically incorrect, but it's confusing at least for me.
[Consuming APIs with Retrofit](https://guides.codepath.com/android/Consuming-APIs-with-Retrofit)
> You can select the Annotation style to Gson, but it's not entirely necessary since the Java file created will work without it.

I've just tried using OMDB API (example:
http://www.omdbapi.com/?i=tt0816692&plot=short&r=json
) and spent some time wondering why most of the values in my object are null, until I realized the problem is most of the attribute names are uppercase, while the variable names are lowercase. With Gson annotations like:

`@SerializedName("Title")`
`@Expose`
`private String title;`

the problem went away.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.