Skip to content Skip to sidebar Skip to footer

Android Retrofit Pojo Model

Hi i'm trying to learn android and now implementing the retrofit 1.9 for my rest POST and GET request can somebody help me on how to model given json objects and strings? im very c

Solution 1:

I think me and you are having the same problems but I am stuck so I can help you as far as I can . First you cannot use jsonschema2pojo.org to create the pojo class you need to use hashmap from what I understand "-KNea90tV5nZlkeqxc3Q": is a key but 1 of the classes should be the following ( also the accountype since its a type you can use enum but it would be bit harder to code)

publicclassAccount {




privateString accountName;

privateString accountNumber;

privateString accountType;


publicAccount() {
                  }




publicStringgetAccountName() {return accountName;}
publicvoidsetAccountName(String accountName) {
 this.accountName=accountName;}

// *** repeat for the accountnumber and accountype

 }

Solution 2:

if the key "KNea90tV5nZlkeqxc3Q" is dynamic and need to capture them, you musto to use a hashmap in your model to catch them correctly.

check this issue it could be useful:

Parse Dynamic Key Json String using Retrofit

Post a Comment for "Android Retrofit Pojo Model"