Add the next dependency to the dependencies
part of /app/construct.gradle.kts
:
implementation("com.google.code.gson:gson:2.9.1")
This lets us deal with the JSON we’ll get again from the API. Now, if we run the app we’ll see some details about Chewbacca:
$ ./gradlew run
> Process :app:run
Title: Chewbacca
Peak: 228
Hair colour: null
Eye colour: null
BUILD SUCCESSFUL in 2s
Conclusion
The great thing about Kotlin for Java builders is that it matches pretty simply into your present psychological mannequin. Kotlin enables you to program contained in the JVM, with all its intensive optimization and huge ecosystem, however with a practical language that’s in some methods “extra Java than Java,” but straightforward to know and highly effective. You can too use Kotlin alongside Java, so that you don’t have to decide on one or the opposite.
There’s much more to Kotlin, together with an extension perform (which helps you to add class features with out subclasses), coroutines, extra practical capabilities, lack of checked exceptions, and a simplified method to object-oriented programming. We’ll proceed exploring Kotlin and its options in my subsequent article.