<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by mahbaleshwar hegde(maabu) on Medium]]></title>
        <description><![CDATA[Stories by mahbaleshwar hegde(maabu) on Medium]]></description>
        <link>https://medium.com/@mahabaleshwarhnr?source=rss-66720b85bd89------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*pOp670nnmYGPKiNB6jwdrA@2x.jpeg</url>
            <title>Stories by mahbaleshwar hegde(maabu) on Medium</title>
            <link>https://medium.com/@mahabaleshwarhnr?source=rss-66720b85bd89------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 06:31:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mahabaleshwarhnr/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Securing Mobile Apps: A Guide to Threat Modeling and Mitigation]]></title>
            <link>https://mahabaleshwarhnr.medium.com/securing-mobile-apps-a-guide-to-threat-modeling-and-mitigation-67420c3d76e0?source=rss-66720b85bd89------2</link>
            <guid isPermaLink="false">https://medium.com/p/67420c3d76e0</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[threat-modeling]]></category>
            <dc:creator><![CDATA[mahbaleshwar hegde(maabu)]]></dc:creator>
            <pubDate>Fri, 26 Jan 2024 19:12:24 GMT</pubDate>
            <atom:updated>2024-02-03T05:45:21.116Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s world, accessing the entire world through mobile devices is remarkably easy. There are plenty of apps available in the market to serve our needs. Mobile apps make people’s lives easier, and they serve as the primary gateway to access any organization’s services; thus, building mobile apps has become a strategic approach. Various aspects, such as UI/UX, tech stack, infrastructure, and security, play a major role in the success of any app. In this blog, we will delve into the security aspects of mobile apps.</p><p>Allow me to share a brief story. “<em>A famous company, XYZ, developed a mobile app with billions of downloads and millions of active users. The app gained fame for its excellent UX and service offerings, making it seem like the perfect app in the market. The company’s business and user engagement were at their peak due to its mobile app. Does the story continue in the same way? Sadly, NO. A hacker explored their mobile app, obtained sensitive information related to the company’s systems, and ultimately shared the data with their competitors. This incident resulted in significant losses and a decline in their users’ credibility. XYZ company had to face numerous consequences due to this incident.</em>” The moral of the story is that security is a crucial aspect of any mobile app that cannot be compromised, along with other key factors.</p><p>Now, let’s delve deeper into addressing security issues during the development stage using Threat Modeling.</p><h3>What is Threat Modeling?</h3><p>Threat modeling is a structured process with the following objectives: identifying security requirements, pinpointing security threats and potential vulnerabilities, quantifying threat and vulnerability criticality, and preventing them during the development stage.</p><h3>Threat Modeling Framework</h3><p>A threat modeling exercise can be completed in four simple steps:</p><ol><li><strong>Assess Scope:</strong> Determine the scope of the project, whether it’s as small as a sprint or as large as an entire system.</li><li><strong>Identify What Can Go Wrong:</strong> This can be as simple as a brainstorming session or a more structured approach using tools.</li><li><strong>Identify Countermeasures or Manage Risk:</strong> Decide how to address each threat. This might involve implementing mitigations or applying risk management approaches such as accept/transfer/eliminate. Keep track of the risks in checkpoints and revisit them if there’s uncertainty or lack of information at the moment.</li><li><strong>Assess Your Work:</strong> Evaluate whether you’ve done a good enough job for the specific system at hand</li></ol><figure><img alt="Threat modelling framework" src="https://cdn-images-1.medium.com/max/1024/1*q9toSSm6_n1rm8oPu5OM6Q.png" /><figcaption>Threat modelling framework</figcaption></figure><h3>Mobile App Threats</h3><p>We can divide threats into 2 categories in mobile apps.</p><ol><li><strong>Known Potential Threats</strong>: Android and iOS</li><li><strong>App Specific Threats</strong>:The extent of threats depends on the application domain, features, and architecture of the app</li></ol><h4><strong>Known Potential Threats</strong>: Android and iOS</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xHOQAenDBWx6stqIzpbj6Q.png" /><figcaption>*All links are attached at the end of the blog.</figcaption></figure><h3>App Specific Threats</h3><ul><li><strong>Log Level</strong>: Logging requests and responses is a common practice in mobile app development during debugging. However, it is crucial to either disable this logging functionality or adjust the log level to error to prevent the inclusion of any sensitive information in the logs.</li><li><strong>Strong Authentication</strong>: Apps should not use basic authentication for fetching and pushing data to backend services. It is highly recommended to employ more secure authentication mechanisms such as OAuth, SAML, etc.</li><li><strong>Finance and Health care Apps Require Extra Security</strong>: Leverage biometric and mPIN features to authenticate finance apps. It is highly recommended to disable the ability to take screenshots of the app and display a blank screen during app switching.</li><li><strong>Source Control Hygiene</strong>: Always encrypt security keys or API keys in the build release pipeline. Additionally, consider adding a git hook to check for sensitive information that has not been committed to the remote source control repository.</li></ul><h3>Threat Modeling in practice.</h3><ul><li><strong>Threat modeling is not a one-time process</strong>; instead, it should be an integral part of the Software Development Life Cycle (SDLC). To enhance security measures, implement security steps and rules within your development pipelines. For instance, tools like SonarQube and MobSF Security Framework provide rapid feedback on potential security breaches. You can proactively identify and address security vulnerabilities throughout the development process. This iterative approach ensures that security considerations are continuously evaluated and refined, contributing to a more robust and secure software environment.</li><li><strong>Use git-hook security tools</strong>: Integrate open-source git-hook tools such as <a href="https://github.com/thoughtworks/talisman">talisman</a>, <a href="https://github.com/awslabs/git-secrets">git-secrets</a>, and <a href="https://github.com/trufflesecurity/trufflehog">trufflehog</a> into your workflow. These tools act as safeguards, preventing the sensitive information in commits to the source control repository.</li><li><strong>Security champions</strong>: Cultivate awareness about threats and security within the team to enhance the overall security of the development process. Designate security champions who assume additional responsibilities alongside the primary development tasks, ensuring that the team adheres to established security practices. These champions play a vital role in maintaining a robust security posture throughout the software development life cycle.</li></ul><h3>Conclusion</h3><p>It is worth investing time setting up the process once and keeping it updated throughout the development. The security of mobile applications or any softwares is crucial and precious. Keeping your application secure helps to maintain the trust of end-users at all times.</p><p>Reference links:</p><p><a href="https://developer.apple.com/documentation/devicecheck/establishing_your_app_s_integrity">Establishing your app&#39;s integrity | Apple Developer Documentation</a></p><p><a href="https://developer.android.com/google/play/integrity">https://developer.android.com/google/play/integrity</a></p><p><a href="https://github.com/scottyab/rootbeer.git">https://github.com/scottyab/rootbeer.git</a></p><p><a href="https://mobile-security.gitbook.io/mobile-security-testing-guide/ios-testing-guide/0x06j-testing-resiliency-against-reverse-engineering#reverse-engineering-tools-detection">https://mobile-security.gitbook.io/mobile-security-testing-guide/ios-testing-guide/0x06j-testing-resiliency-against-reverse-engineering#reverse-engineering-tools-detection</a></p><p><a href="https://stackoverflow.com/questions/2799097/how-can-i-detect-when-an-android-application-is-running-in-the-emulator/21505193#21505193">https://stackoverflow.com/questions/2799097/how-can-i-detect-when-an-android-application-is-running-in-the-emulator/21505193#21505193</a></p><p><a href="https://owasp.org/www-project-mobile-app-security/">https://owasp.org/www-project-mobile-app-security/</a></p><p><a href="https://owasp.org/www-community/Threat_Modeling">https://owasp.org/www-community/Threat_Modeling</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67420c3d76e0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dissecting the iOS UITableView]]></title>
            <link>https://mahabaleshwarhnr.medium.com/dissecting-the-ios-uitableview-cc3e19401ffd?source=rss-66720b85bd89------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc3e19401ffd</guid>
            <category><![CDATA[uitableview]]></category>
            <category><![CDATA[uitableviewcell]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[uitableviewcontroller]]></category>
            <dc:creator><![CDATA[mahbaleshwar hegde(maabu)]]></dc:creator>
            <pubDate>Mon, 10 Jul 2023 09:43:07 GMT</pubDate>
            <atom:updated>2023-07-10T13:01:02.006Z</atom:updated>
            <content:encoded><![CDATA[<p>Nowadays, most mobile apps fetch data from backend services, ranging from small information to large files or never-ending scrolling data. Despite the introduction of SwiftUI, UIKit is still widely used. To handle dynamic data display, Apple provides UITableView APIs since iOS version 2.0. In this article, I will cover the fundamental concepts of UITableView and its important APIs.</p><p><strong>What is UITableView?</strong></p><p>From the apple documentation — <em>Table views in iOS display rows of vertically scrolling content in a single column. Each row in the table contains one piece of your app’s content. For example, the Contacts app displays the name of each contact in a separate row, and the main page of the Settings app displays the available groups of settings. You can configure a table to display a single long list of rows, or you can group related rows into sections to make navigating the content easier.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*xYJcR5ioMHPam0Vrx4d-cQ@2x.png" /></figure><p>In simple words, a table view presents data in rows, following a predefined prototyped UI, and allows vertical scrolling exclusively.</p><p><strong>Parts of TableView</strong></p><ol><li><strong>Table View Header:</strong> The view that is displayed above the table’s content. This view is always attached to the top of the table view. Developer often get confused with tableview header with section header. They are different.</li><li><strong>Table View Footer:</strong> The view that is displayed below the table’s content. This view is always attached to the bottom of the table view. It differs from the table view’s section footer. Developer often get confused with tableview footer with section footer. They are different.</li><li><strong>Table View Rows (Cells):</strong> This is the main part of the table view where the table’s content is displayed. Developers can create multiple cells to display different kinds of prototype UI. Each cell must have a unique reuse identifier, which can be used to reuse the cell when the user scrolls, rather than creating a new cell. You can read more about reuseIdentifier <a href="https://stackoverflow.com/questions/30473833/what-is-the-purpose-of-the-reuseidentifier">here</a>.</li><li><strong>Table Sections:</strong> The table view can be divided into multiple sections. Each section can have a different number of rows. By default, the table view has only one section.</li><li><strong>Table Section Header:</strong> Each section can have a header, which can be reused in different sections, similar to table view cells.</li><li><strong>Table Section Footer:</strong> Each section can have a footer, which can also be reused in different sections, similar to table view cells.</li><li><strong>IndexPath:</strong> IndexPath is a data structure that can be constructed with row and section values. It is used to configure rows, section headers, and section footers of the table view. IndexPath is also used for retrieving the configured cell, header, or footer. By default, the IndexPath row and section starts from 0.</li></ol><p>Let’s write a simple diagram that combines all the different parts of UITableView into one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*dbFopZmIqowQUGURGL84mQ.png" /></figure><p>To understand how data can be displayed in a table view, UITableView provides datasource and delegate methods. These methods allow you to display any complex UI. I will cover only the important methods that can be used to configure different parts of the table view as explained above.</p><h4>Configure tableview header and footer</h4><pre>let tableView = UITableView()<br>tableView.tableHeaderView = // tableheader<br>tableView.tableFooterView = // tablefooter</pre><p><strong>UITableViewDataSource Methods</strong></p><pre>var blogPosts = [BlogPost]()<br><br>extension ViewController: UITableViewDataSource {<br>    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {<br>        // You can configure table rows here.<br>        let blogPost = blogPosts[indexPath.row]<br>        let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath)<br>        var content = cell.defaultContentConfiguration()<br>        content.text = blogPost.title<br>        content.secondaryText = blogPost.body<br>        cell.contentConfiguration = content<br>        return cell<br>    }<br>    <br>    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {<br>        // you can return number of rows based on section<br>        if section == 0 {<br>            return 10<br>        } else {<br>            return 1<br>        }<br>    }<br>    <br>    func numberOfSections(in tableView: UITableView) -&gt; Int {<br>        // you can return number of sections<br>        return 2<br>    }<br>}</pre><p><strong>UITableViewDelegate Methods</strong></p><pre>extension ViewController: UITableViewDelegate {<br>    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -&gt; UIView? {<br>        guard section == 0 else {<br>            return nil<br>        }<br>        return tableView.dequeueReusableHeaderFooterView(withIdentifier: identifier)<br>    }<br>    <br>    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -&gt; UIView? {<br>        return UIView()<br>    }<br>}</pre><p>I encourage you to explore other UITableView datasource and delegate methods as well. I hope this helps you understand the UITableView better.</p><p>Thank you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc3e19401ffd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JSON Serialization using Kotlin native Serialization.]]></title>
            <link>https://mahabaleshwarhnr.medium.com/json-serialization-using-kotlin-native-serialization-c8395bb46762?source=rss-66720b85bd89------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8395bb46762</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[json-parsing]]></category>
            <category><![CDATA[json-serialization]]></category>
            <category><![CDATA[kotlin-serialization]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[mahbaleshwar hegde(maabu)]]></dc:creator>
            <pubDate>Sun, 28 Mar 2021 16:03:36 GMT</pubDate>
            <atom:updated>2021-03-29T05:50:04.704Z</atom:updated>
            <content:encoded><![CDATA[<h3>Kotlin JSON Serialization using kotlinx.serialization</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1gCppTwAq0RxQ2NX" /><figcaption>Photo by <a href="https://unsplash.com/@mreichelt?utm_source=medium&amp;utm_medium=referral">Marc Reichelt</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I have been working on android app development for the last 1.5 years. I have to use parsing libraries to encode and decode JSON objects. There are many popular libraries like GSON, Moshi to serialize and deserialize objects. I majorly used GSON in my projects. But there are some limitations when we use GSON library with Kotlin.</p><p>Let’s take a look at below example</p><pre>import com.google.gson.Gson<br><br>data class User(val firstName: String,<br>                val lastName: String = &quot;Appleased&quot;) {<br><br>    val fullName: String<br>        get() = &quot;$firstName $lastName&quot;<br>}<br><br>fun main() {<br>    val json = &quot;&quot;&quot;<br>        {<br>           &quot;firstName&quot;: &quot;John&quot;<br>        }<br>    &quot;&quot;&quot;.<em>trimIndent</em>()<br>    val user = Gson().fromJson(json, User::class.<em>java</em>)<br>    <em>println</em>(user.fullName)<br>    <em>print</em>(user.lastName.<em>isBlank</em>())<br>}</pre><pre>Output:  John null.<br>         App crashes.</pre><p>We have lost 2 major features of kotlin:</p><ol><li>Type Safety- lastname property is non nullable but GSON still can parse null string to create a user object.</li><li>Argument’s default value has no effect.</li></ol><p>You can find similar kinds of other problems and workaround solutions over the internet. Kotlin team has come up with the native support library <a href="https://github.com/Kotlin/kotlinx.serialization">kotlinx.serialization</a>. This library provides supports for all supported platforms — JVM, JavaScript, Native — and for various serialization formats — JSON, CBOR, protocol buffers, and others.</p><h3><strong>Get Started with kotlinx.serialization</strong></h3><p>As I mentioned earlier kotlinx.serialization includes libraries for various serialization formats like <a href="https://www.json.org/">JSON</a>, <a href="https://developers.google.com/protocol-buffers">Protocol buffers</a>, <a href="https://cbor.io/">CBOR</a>, <a href="https://en.wikipedia.org/wiki/.properties">Properties</a>, <a href="https://github.com/lightbend/config/blob/master/HOCON.md">HOCON</a>. This article covers only on kotlinx.serialization JSON serialization basics.</p><h4><em>Installation</em></h4><pre>//use your project kotlin version.<br>plugins {<br>    id &#39;com.android.application&#39;<br>    id &#39;kotlin-android&#39;<br>    id &#39;org.jetbrains.kotlin.plugin.serialization&#39; version &#39;1.4.30&#39;   <br>    id &#39;org.jetbrains.kotlin.jvm&#39; version &#39;1.4.30&#39;<br>}</pre><pre>dependencies {<br>  implementation &quot;org.jetbrains.kotlinx:kotlinx-serialization- json:1.1.0&quot;<br>}</pre><h4><strong>JSON Encoding</strong></h4><p>First, make a class serializable by annotating it with @Serializable</p><pre>@Serializable<br>data class Project(val name: String, val language: String)<br><br>fun main() {<br>    val project = Project(&quot;kotlinx.serialization&quot;, &quot;Kotlin&quot;)<br>    val jsonString = Json.<em>encodeToString</em>(project)<br>    <em>print</em>(jsonString) <br>}</pre><pre>Output: {&quot;name&quot;:&quot;kotlinx.serialization&quot;,&quot;language&quot;:&quot;Kotlin&quot;}</pre><h4>JSON Decoding</h4><pre>@Serializable<br>data class Project(val name: String, val language: String)<br><br>fun main() {<br>    val jsonString = &quot;&quot;&quot;<br>        {&quot;name&quot;:&quot;kotlinx.serialization&quot;,&quot;language&quot;:&quot;Kotlin&quot;}<br>    &quot;&quot;&quot;.<em>trimIndent</em>()<br>    val project: Project = Json.<em>decodeFromString</em>(jsonString)<br>    <em>print</em>(project)<br>}<br>Output: Project(name=kotlinx.serialization, language=Kotlin)</pre><p>Lets dive into few important features of kotlinx.serialization.</p><h4>1. Type Safety Enforced</h4><p>kotlinx.serialization API ensures type safety. You cannot create an object from a null value where the constructor parameter expects a non-nullable value.</p><pre>@Serializable<br>data class Project(val name: String, val language: String)<br><br>fun main() {<strong><br>    </strong>val jsonString = &quot;&quot;&quot;<br>        {&quot;name&quot;:&quot;kotlinx.serialization&quot;, &quot;language&quot;: null}<br>    &quot;&quot;&quot;.<em>trimIndent</em>()<br>    val project: Project = Json.<em>decodeFromString</em>(jsonString)<br>    <em>print</em>(project)<br>}<br>Output: Exception in thread &quot;main&quot; kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 45: Expected string literal but &#39;null&#39; literal was found.</pre><h4><strong>2. Supports default value in JSON decoding</strong></h4><p>kotlinx.serialization API supports default value of kotlin when decoding JSON string. You must use Json builder API and set coerceInputValuesto true.</p><pre>@Serializable<br>data class Project(val name: String, val language: String = &quot;kotlin&quot;)<br><br>fun main() {<br>   val json = <em>Json </em><strong>{<br>        </strong>coerceInputValues = true<br>    <strong>}<br>    </strong>val jsonString = &quot;&quot;&quot;<br>        {&quot;name&quot;:&quot;kotlinx.serialization&quot;, &quot;language&quot;: null}<br>    &quot;&quot;&quot;.<em>trimIndent</em>()<br>    val project: Project = json.<em>decodeFromString</em>(jsonString)<br>    <em>print</em>(project)<br>}<br> Output: Project(name=kotlinx.serialization, language=kotlin)</pre><h4><strong>3</strong>. <strong>Generic classes</strong></h4><p>kotlinx.serialization API encode and decodes generic class type very easily and efficiently.<br>Encoding:</p><pre>@Serializable<br>data class Version(val major: String, <br>                   val minor: String, <br>                   val patch: String)<br>@Serializable<br>data class Number&lt;T&gt;(val value: T)<br>@Serializable<br>data class Data(val intNumber: Number&lt;Int&gt;, <br>                val longNumber: Number&lt;Long&gt;, <br>                val versionNumber: Number&lt;Version&gt;)<br><br>fun main() {<br>    val data = Data(Number(10),<br>            Number(10L),<br>            Number(Version(&quot;1&quot;, &quot;0&quot;, &quot;0&quot;)))<br>    val encodedString = Json.<em>encodeToString</em>(data)<br>    <em>print</em>(encodedString)<br>}<br>Output: {&quot;intNumber&quot;:{&quot;value&quot;:10},&quot;longNumber&quot;:{&quot;value&quot;:10},&quot;versionNumber&quot;:{&quot;value&quot;:{&quot;major&quot;:&quot;1&quot;,&quot;minor&quot;:&quot;0&quot;,&quot;patch&quot;:&quot;0&quot;}}}</pre><p>Decoding:</p><pre>@Serializable<br>data class Project(val name: String, val language: String)<br>fun main() {<br><br>    val jsonString = &quot;&quot;&quot;<br>        [<br>          {<br>            &quot;name&quot;: &quot;kotlinx.serialization&quot;,<br>            &quot;language&quot;: &quot;kotlin&quot;<br>           }, <br>          {<br>            &quot;name&quot;: &quot;coroutines&quot;,<br>            &quot;language&quot;: &quot;kotlin&quot;<br>          }<br>        ]<br>    &quot;&quot;&quot;.<em>trimIndent</em>()<br>    <strong>val projects: List&lt;Project&gt; = Json.<em>decodeFromString</em>(jsonString)</strong><br>    <em>print</em>(projects)<br>}<br>Output: [Project(name=kotlinx.serialization, language=kotlin), Project(name=coroutines, language=kotlin)]</pre><p>We have not used any anonymous TypeToken object to get the generic type of converting object like in GSON or any Java based libraries. So no anonymous TypeToken object is required to decode the Generic kotlin types in kotlinx.serialization 😎.</p><h4><strong>4</strong>. <strong>Serial field names</strong></h4><p>There are often cases when Json key is different from their property name. we can add annotate property name with @SerialName(&quot;json_key&quot;)</p><pre>@Serializable<br>data class Project(val name: String,<br>                  @SerialName(&quot;lang) val language: String)</pre><h4>5. <strong>Referenced objects</strong></h4><p>kotlinx.serialization supports nested object serialization. It only serializes property or class which are annotated as@Serializable, otherwise compiler throws the error:</p><pre>@Serializable<br>data class Project(val name: String,<br>                  val language: String,<br>                   val project: Version<br>)<br>@Serializable // if you remove annotation compiler throws error.<br>data class Version(val major: Int,<br>                   val minor: Int,<br>                   val patch: Int)<br>Output: {&quot;name&quot;:&quot;Jetpack&quot;,&quot;language&quot;:&quot;Kotlin&quot;,&quot;project&quot;:{&quot;major&quot;:1,&quot;minor&quot;:0,&quot;patch&quot;:0}}</pre><h4><strong>6. Data Validation</strong></h4><p>You can validate the data at the time of decoding json.</p><pre>@Serializable<br>data class LoginResponse(val accessToken: String) {<br>    init {<br>        <em>require</em>(accessToken.<em>isNotEmpty</em>()) <strong>{ </strong>&quot;Access token cannot be empty&quot; <strong>}<br>    </strong>}<br>}<br><br>fun main() {<br><br>    val jsonString = &quot;&quot;&quot;<br>         { &quot;accessToken&quot;: &quot;&quot; }<br>    &quot;&quot;&quot;.<em>trimIndent</em>()<br>    val loginResponse: LoginResponse = Json.<em>decodeFromString</em>(jsonString)<br>}</pre><pre>Output: Exception in thread &quot;main&quot; java.lang.IllegalArgumentException: Access token cannot be empty</pre><h3>Retrofit support</h3><p>You can check the awesome <a href="https://github.com/JakeWharton/retrofit2-kotlinx-serialization-converter">library</a> for Retrofit 2 Converter.Factory for Kotlin serialization</p><h3>Final Thoughts</h3><p><a href="https://github.com/Kotlin/kotlinx.serialization">kotlinx.serialization</a> has a lot of good features. I have covered only the basics in this article. You can explore more features in their official <a href="https://github.com/Kotlin/kotlinx.serialization">documentation</a>.</p><p>Happy coding ❤️😁</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8395bb46762" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>