G
G
grupsa2017-02-13 18:57:29
Android
grupsa, 2017-02-13 18:57:29

Retrofit How to map fields from JSON response to non-matching model fields?

Suppose the web service returns a JSON user object: {"user_ig"="32432", "user_name"="Ivan"}
I use Retrofit and GSON and having a User class with fields 'user_id' and 'user_name' I get the parsed object without problems.
But what should I do if I do not want the field names of my model to depend on a third-party service:

Class User {
    public id;
    public name;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2017-02-13
@grupsa

@SerializedName

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question