0
My question is how to take the request JSON and put it in an Arraylist so I can inflate the Recyclerview. Thanks in advance.
0
My question is how to take the request JSON and put it in an Arraylist so I can inflate the Recyclerview. Thanks in advance.
1
Adds a CoverterFactory
the instantiation of Retrofit
, through the addConverterFactory
, and in case JSON returns an Array, you can easily map it to an Arraylist.
0
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: https://www.devmedia.com.br/trabalhando-com-json-em-java-o-pacote-org-json/25480
Another alternative would be the GSON library, in which you directly convert an Object to Json and a Json to Object. Link: http://www.vogella.com/tutorials/JavaLibrary-Gson/article.html
I managed to fix it. Thanks for the help!
Browser other questions tagged android android-recyclerview retrofit
You are not signed in. Login or sign up in order to post.
Thanks! I got it right.
– Erom Freitas