questa è la mia prima risposta JSON e ho ottenuto il tokenRetrofit 2 come ottenere la risposta da oggetti JSON nidificati (Android)
{
"token": "I0ZmEifQ.CdbGWjkIYnuO29uJokCIGn8kXFbLbVp3gnlsEszagno"
}
classe POJO
public class TokenReceiver {
private String token;
public String getToken() {
return token;
}
}
quanto sopra ha funzionato bene, ma come per ottenere la risposta per il seguito
{
"user": {
"id": 1,
"first_name": "Super",
"last_name": "Admin",
"email": "[email protected]",
"mobile_no": 2147483647,
"created_at": "2016-01-21 00:00:00",
"updated_at": "2016-01-21 00:00:00",
"user_role_id": 1
}
}
il codice di stato 200 (OK) , ma il dato non è g reparativi attaccato al POJO
public class User {
@SerializedName("id")
@Expose
private int id;
@SerializedName("first_name")
@Expose
private String first_name;
@SerializedName("last_name")
@Expose
private String last_name;
@SerializedName("email")
@Expose
private String email;
@SerializedName("mobile_no")
@Expose
private String mobile_no;
@SerializedName("created_at")
@Expose
private String created_at;
@SerializedName("updated_at")
@Expose
private String updated_at;
@SerializedName("user_role_id")
@Expose
private int user_role_id;
}
grazie in anticipo
Spero che ti possa aiutare! apri questo http://www.jsonschema2pojo.org/ e seleziona il tipo di fonte: JSON e lo stile di annotazione: GSON e scarica il JSON completo lì, avrai pronto pojo completo, che potrai incollarlo nel tuo codice progetto. e quella classe POJO che puoi impostare come CallBack in Retrofit! – Rahul