O'Reilly logo

Mastering Android Development with Kotlin by Miloš Vasić

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Introduction to Gson with Kotson library

JSON serialization and deserialization are very important for every Android application and are frequently used. For that purpose, we will be using the Gson library developed by Google. Also, we will use Kotson and Kotlin bindings for Gson. So, let's start!

First of all, we need to provide dependencies for our build.gradle configuration as follows:

    apply plugin: "com.android.application" 
    apply plugin: "kotlin-android" 
    apply plugin: "kotlin-android-extensions" 
    ... 
    dependencies { 
      ... 
      compile 'com.google.code.gson:gson:2.8.0' 
      compile 'com.github.salomonbrys.kotson:kotson:2.3.0' 
      ... 
    } 

We will update our code to use Gson with Kotson bindings for location serialization/deserialization in database management. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required