My question is how do I get the JSON of the request and put it in an ArrayList so that I can inflate the RecyclerView. Thanks in advance.
My question is how do I get the JSON of the request and put it in an ArrayList so that I can inflate the RecyclerView. Thanks in advance.
Adds a CoverterFactory
to the instantiation of Retrofit
, via addConverterFactory
, and in case JSON returns an Array, you can easily map it to an ArrayList.
You can convert your JSON into a JsonObject and go capturing its attributes.
JSON
{
"nome": "José da Silva"
"idade" : 30
}
JAVA
JSONObject jsonObj= new JSONObject("seu json aqui");
String nome = jsonObj.getString("nome");
int idade = jsonObj.getInt("idade");
Exit
Log.d("App", "Nome: " + nome);//José da Silva
Log.d("App", "Idade: " + idade);//30
Reference: link
Another alternative would be the GSON library, in which you directly convert an Object to Json and a Json to Object. Link: link