Question

I am just simply trying to use retrofit to perform my rest api calls. The issue that I am facing is that when parsing the json, some of the key fields contain dots. For example:

{ "data": { "name.first": "first name"} }

Is it possible to configure Retrofit (or GsonConverter) to be able to handle this and how do I go about doing so?

Was it helpful?

Solution

This is neither Retrofit nor the GsonConverter's responsibility but rather Gson which sits underneath doing the actual JSON (de)serialization.

You can use Gson's @SerializedName annotation to work around names which cannot be represented in Java:

@SerializedName("name.first")
public final String firstName;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top