DEV Community

Cover image for Android-Kotlin,Get data from restful API having multiple JSON objects.

Android-Kotlin,Get data from restful API having multiple JSON objects.

Benard Ngoda on June 14, 2020

Hello There, i am delighted that you landed onto my article. In this Article i will teaching you how to fetch data from restful API having multiple...
Collapse
 
chinghsuanwei profile image
chinghsuanwei • Edited

I think the author just forget to past code of country_item.xml, so I just want to make the project completed by adding the missing file.

Here is the my github link: github.com/chinghsuanwei/CovidLog

Feel free to tell me to delete repo, if you think it's not OK.

Collapse
 
ndiritumichael profile image
Michael Ndiritu

Nice article but I have found some issues with the JSON contents you posted.
also could you please post the code on Github for references.

Collapse
 
bensalcie profile image
Benard Ngoda

Hello,sorry for this...i will post the code on github and clarify as well

Collapse
 
pkbiswal321 profile image
pkbiswal321

where this code in github?

Collapse
 
raymond6289 profile image
Raymond6289

Thank you very much for this guidance. I have a query. I tried to use a variable in the @GET expression but get the following compiler error:

“Only ‘const val’ can be used in constant expressions.”

Can you advise me how to get around this problem please? Thank you.

Collapse
 
michelp3 profile image
michelp3

Hello android studio 4 : convert Json to kotlin
data class CountryInfo(
val _id: Int,
val flag: String,
val iso2: String,
val iso3: String,
val lat: Int,
val long: Int
)
error nothing to screen
Explication ???
My english is bad
Best regards

Collapse
 
alos1895 profile image
alos1895

Hi, I think just forget to put the code for country_item.xml. But Works excellent

Collapse
 
michelp3 profile image
michelp3

Explication
MyCountry
val criticalPerOneMillion: Double,

CountryInfo
val lat: Double
val long: Double

With Modifications : OK but android studio 4 : convert Json to kotlin is not correct ??