Now that we know the basic concepts of kotlin serialization and have also seen how to use it to serialize and deserialize data, let’s talk a bit about the library’s internal working and some of the important concepts.

Note: If you haven’t gone through the previous posts, you should take a look at those first.

The entire process of serialization is composed of two separate sub-processes:

  1. Serialization
  2. Encoding

Each of these processes has a single responsibility, which enables clear separation of roles and allows both to operate independently. This is the reason behind the extensibility and flexibility of the library…


In the previous posts we learned about the basics of kotlin serialization. We instantiated a Json object, passing it a configuration and used it to perform serialization and deserialization operations. This post is about that configuration, called JsonConfiguration — why is it required and what role does it play in the process.

The JsonConfiguration class is provided by the serialization runtime library and allows us to customise JSON behaviour as per our requirements. It is a simple data class with various properties and two out-of-the-box configurations:

  1. Stable — adheres to the JSON specification restrictions (RFC-4627) and is guaranteed to preserve…


When interacting with a Rest API, it’s common to have some optional properties in the response. These properties might or might not be present at runtime. Let’s consider we updated out User data object to contain a required, non-nullable and unique id and age, which is an optional, nullable property.

@Serializable
data class User(
val id: String,
val name: String,
val age: Int? = null
)

(You can see all these examples as a series of unit tests here in this gist)

Handling optional values

Kotlin’s features — especially its nullable types and default parameter values prove to be great when dealing with…


Kotlin serialization is kotlin-first, compile-time, type-safe, reflection-free and completely multi-platform ready serialization mechanism to convert kotlin objects into data formats like JSON or Protobuf and vice-versa.
It is comprised of a compiler plugin which is used to generate code for serializable classes and a runtime library, containing core classes and primitives for serialization & IO, among some other things.


Knowing keyboard shortcuts is important. They save you time and help you achieve more in less time. If you need convincing, I highly recommend watching ‘Mouseless Driven Development’ by Hadi Hariri.

This blog post is about one such feature of Android Studio (or any JetBrains IDE for that matter) which not a lot of people know about — multi-caret selection. A lot of my friends and colleagues who I pair-program with feel amazed by it and always ask “What was that!?”, so I decided to write about it to help them and everyone out there know about these.

Why use…


The story of lazy collection operations

Transforming, filtering, manipulating and operating on data is what every developer does almost every day at their jobs. If you’re using Kotlin for writing your applications, you might have used map or filter operator to transform a collection from one form to another.

Along with the kotlin.collections package, Kotlin also provides a way to lazily represent and evaluate a collection of data. This is accomplished using Sequences.

Sequences are a collection of possibly infinite data, ordered in a certain way.

Sequences are a part of the language standard library and allow lazy evaluation of large amount of data (in millions)…


Anyone who has been developing android application knows how memory-scarce the platform is, with each application being provided with upto 24/32mb of memory (which can go to as low as 16mb for older devices)*. In such a scenario, it is the developer’s duty to look out for memory leaks and free any resources that are not been used by the application.

One way of managing memory in response to system events is the onTrimMemory() method. From the docs:

onTrimMemory(): Called when the operating system has determined that it is a good time for a process to trim unneeded memory from…


[For more info: https://realm.io]

I have recently been working with people at Untrodden Labs as an android developer, was assigned to create the android app for their product. I was also given the freedom to choose whatever libraries/stack I deem necessary.

This seemed to be a great opportunity to (finally)experiment with realm and find whether its actually that good or not.

Getting Started:

This is quite simple, as given in their docs:

  1. Add the classpath "io.realm:realm-gradle-plugin:X.X.X" dependency to your project level build.gradle file.
  2. Add apply plugin: 'realm-android' to top of your app level build.gradle file.

Sync the changes, and init Realm in…


So i’ve been pondering and have decided to (finally) start writing a blog. I’ll be writing things that I learn during my daily tasks — development, studies, life-lessons, crazy-stuff — basically anything that I think might help someone. Also, please neglect any typos, grammar errors, blunt views, use of foul language.

What’s Next?

Aiming to post at-least one post (Oh God Why?) every week and find new things to learn during the process.

Cheers!

Gurpreet Singh

Learner. Inquisitive. Embraces Functional & Reactive programming and TDD. Likes experimenting. Trying to read & write well. Also, Google certified Android Dev.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store