https://kotlinlang.org logo
#kotlin-fuel
Title
# kotlin-fuel
n

Ncrnomarkovic

11/24/2020, 7:17 PM
1st time using Fuel to make an http request and parse it into an object using the following tutorial: https://medium.com/@paul.allies/kotlin-http-get-with-deserialization-with-fuel-12691904e30b I don't understand the part about Gson. Looks like I don't have it defined in my gradle. Is this article's implementation the way to go? Is Fuel a good networking and parsing library? Advice appreciated - thank you
☝️ 1
t

Tony Mykhaylovsky

11/24/2020, 7:53 PM
I'm curious about this as well
k

kittinunf

11/25/2020, 10:38 AM
It looks okay to me, which part you don’t understand?
for example, let’s use Github issue as example … Given this https://api.github.com/repos/kittinunf/Fuel/issues/1 I might create my object like this
Copy code
data class Issue(
        val id: Int = 0,
        val title: String = "",
        val url: String = ""
    ) {
        class Deserializer : ResponseDeserializable<Issue> {
            override fun deserialize(reader: Reader) = Gson().fromJson(reader, Issue::class.java)!!
        }
}
Then you plug the class into the
responseObject
n

Nikky

11/25/2020, 2:09 PM
i definitly prefer using koltinx-serilaization whenver circumstances allow.. or jackson if not.. gson has the bad habit of sneaking nulls in non-nullable values in kotlin classes
t

Tony Mykhaylovsky

11/26/2020, 5:36 AM
@kittinunf Thank you. It works for one issue. How can I parse this endpoint https://api.github.com/repos/kittinunf/Fuel/issues ?
k

kittinunf

11/26/2020, 5:38 AM
Add another one for
List<Issue>
?
90 Views