# Gson

Gson is a Java library for converting Java objects to and from JSON.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Kotlin JSON Benchmark on Android (2022): Moshi vs Kotlin Serialization

DevFeed: [Kotlin JSON Benchmark on Android (2022): Moshi vs Kotlin Serialization](<https://devfeed.tech/articles/kotlin-json-benchmark-on-android-2022-moshi-vs-kotlin-serialization-25881.md>)

Original publisher: [Read original article](<https://bladecoder.medium.com/kotlin-json-benchmark-on-android-2022-moshi-vs-kotlin-serialization-18436c0596c3?source=rss-54910f05af37------2>)

Author: Christophe Beyls

Published: 2022-10-14T17:31:03Z

Content type: comparison

Language: en

Sources: [Stories by Christophe Beyls on Medium](<https://devfeed.tech/sources/stories-by-christophe-beyls-on-medium.md>)

Topics: [JSON](<https://devfeed.tech/topics/json.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Benchmark](<https://devfeed.tech/topics/benchmark.md>), [Gson](<https://devfeed.tech/topics/gson.md>), [build times](<https://devfeed.tech/topics/build-times.md>), [Code generation](<https://devfeed.tech/topics/code-generation.md>), [legacy](<https://devfeed.tech/topics/legacy.md>)

Tags: [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [annotation-processor](<https://devfeed.tech/tags/annotation-processor.md>), [benchmark](<https://devfeed.tech/tags/benchmark.md>), [gson](<https://devfeed.tech/tags/gson.md>), [json](<https://devfeed.tech/tags/json.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-serialization](<https://devfeed.tech/tags/kotlin-serialization.md>), [legacy](<https://devfeed.tech/tags/legacy.md>), [moshi](<https://devfeed.tech/tags/moshi.md>), [performance](<https://devfeed.tech/tags/performance.md>), [serialization](<https://devfeed.tech/tags/serialization.md>), [vs](<https://devfeed.tech/tags/vs.md>)

### AI overview

This article sets up a 2022 Android benchmark comparing Moshi and Kotlin Serialization for JSON serialization and deserialization of Kotlin classes. It discusses Kotlin metadata compatibility, generated adapters, reflection, streaming support, Okio integration, runtime dependencies, and build-time tradeoffs. The supplied text does not include the benchmark results or identify which library is fastest.

### Source excerpt

When it comes to automatic serialization and deserialization of Kotlin classes using the JSON format, the two main libraries compatible with Kotlin metadata are currently Moshi and Kotlin Serialization. This compatibility is especially important for non-null types and default values during deserialization, where lack of proper Kotlin support could result in unexpected values occurring at runtime, such as null values in non-null fields. If you're still using legacy libraries like Gson to parse Kotlin classes, it's time to reconsider. Moshi has been supporting Kotlin classes since version 1.5.0, released in 2017. One year later, the next major release 1.6.0 added an annotation processor to generate adapters for Kotlin classes at compile time. I was quite interested in the performance gains allowed by this solution and wrote an article detailing what the generated code does. JetBrains released version 1.0.0 of Kotlin Serialization in 2020 with built-in support for JSON. This library generates adapters at compile time similarly to Moshi's annotation processor while being compatible with more platforms and formats. The lack of initial support for streaming was disappointing, so I didn't even consider using it in production until streaming support was eventually added in version 1.3.0 in 2021. The JSON engine had also been rewritten in the meantime in order to improve performance. Recently, version 1.4.0 added integration with the Okio library, the same library used by Moshi under the hood. Now that Kotlin Serialization looks full-featured and well-optimized, I thought it would be a good time to compare its performance against Moshi on Android devices with some benchmarks. Which one is the fastest? Take your bets. The contendersMoshi-Kotlin Reflection The runtime Kotlin plugin of the Moshi library. The JSON adapters are generated at runtime using reflection. The main downside of this library is that it adds a runtime dependency to the big kotlin-reflect library (currently

## Gson failure in end-to-end tests

DevFeed: [Gson failure in end-to-end tests](<https://devfeed.tech/articles/gson-failure-in-end-to-end-tests-27330.md>)

Original publisher: [Read original article](<https://blog.pchudzik.com/202201/gson-fail/>)

Published: 2022-01-23T00:00:00Z

Content type: article

Language: en

Sources: [Paweł Chudzik](<https://devfeed.tech/sources/pawe-chudzik.md>)

Topics: [Gson](<https://devfeed.tech/topics/gson.md>), [Java](<https://devfeed.tech/topics/java.md>), [JSON](<https://devfeed.tech/topics/json.md>), [Testing](<https://devfeed.tech/topics/testing.md>), [Jackson](<https://devfeed.tech/topics/jackson.md>)

Tags: [e2e](<https://devfeed.tech/tags/e2e.md>), [enum](<https://devfeed.tech/tags/enum.md>), [gson](<https://devfeed.tech/tags/gson.md>), [jackson](<https://devfeed.tech/tags/jackson.md>), [java](<https://devfeed.tech/tags/java.md>), [json](<https://devfeed.tech/tags/json.md>), [tests](<https://devfeed.tech/tags/tests.md>), [work](<https://devfeed.tech/tags/work.md>)

### AI overview

This article explains that Gson can silently ignore JSON deserialization problems, such as an unknown enum value, allowing end-to-end tests to pass even when an API contract is broken. It contrasts this behavior with Jackson and describes migrating tests from Gson to Jackson.

### Source excerpt

Using Gson in your e2e tests might result in tests passing even when contract is broken. Gson is quite imprecise when it comes to deserializing objects from json. Is there any difference between an enum and a string? Is there any difference between s string and a number? Using Java you might answer: sure there is. Even when talking about JSON you'll answer: yeah there is a difference. But for GSON? Meh whatever. Read more

## How to use Retrofit on android with Kotlin (KAD 21)

DevFeed: [How to use Retrofit on android with Kotlin (KAD 21)](<https://devfeed.tech/articles/how-to-use-retrofit-on-android-with-kotlin-kad-21-27224.md>)

Original publisher: [Read original article](<https://antonioleiva.com/retrofit-android-kotlin>)

Published: 2017-04-18T00:00:00Z

Content type: tutorial

Language: en

Sources: [Antonio Leiva](<https://devfeed.tech/sources/antonio-leiva.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [API](<https://devfeed.tech/topics/api.md>), [Library](<https://devfeed.tech/topics/library.md>), [Gradle](<https://devfeed.tech/topics/gradle.md>), [Gson](<https://devfeed.tech/topics/gson.md>), [Java](<https://devfeed.tech/topics/java.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [api](<https://devfeed.tech/tags/api.md>), [build](<https://devfeed.tech/tags/build.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [gson](<https://devfeed.tech/tags/gson.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [java](<https://devfeed.tech/tags/java.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [okhttp](<https://devfeed.tech/tags/okhttp.md>), [retrofit](<https://devfeed.tech/tags/retrofit.md>)

### AI overview

A Kotlin tutorial showing how to integrate Retrofit 2 into an Android application for making LastFM API requests. It covers Gradle dependencies, OkHttp logging, Gson conversion, request interfaces, service initialization, and making requests with extension functions.

### Source excerpt

Everything Android, Kotlin and other random topics

## Moshi, another JSON Processor

DevFeed: [Moshi, another JSON Processor](<https://devfeed.tech/articles/moshi-another-json-processor-15770.md>)

Original publisher: [Read original article](<https://developer.squareup.com/blog/moshi-another-json-processor>)

Author: Jesse Wilson

Published: 2017-03-27T19:50:19Z

Content type: opinion

Language: en

Sources: [Square Corner Blog RSS Feed](<https://devfeed.tech/sources/square-corner-blog-rss-feed.md>)

Topics: [JSON](<https://devfeed.tech/topics/json.md>), [Library](<https://devfeed.tech/topics/library.md>), [Gson](<https://devfeed.tech/topics/gson.md>), [Dagger](<https://devfeed.tech/topics/dagger.md>), [Dependency injection](<https://devfeed.tech/topics/dependency-injection.md>), [Mobile](<https://devfeed.tech/topics/mobile.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [dagger](<https://devfeed.tech/tags/dagger.md>), [dependency-injection](<https://devfeed.tech/tags/dependency-injection.md>), [development](<https://devfeed.tech/tags/development.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [gson](<https://devfeed.tech/tags/gson.md>), [json](<https://devfeed.tech/tags/json.md>), [library](<https://devfeed.tech/tags/library.md>), [moshi](<https://devfeed.tech/tags/moshi.md>)

### AI overview

The article introduces Moshi, a JSON library created to apply lessons from Gson. It describes problems with Gson's date handling and lenient parsing, and explains Moshi's goal of being small, efficient, and safe by default.

### Source excerpt

It's rare for a programmer to get to work on the same problem twice. Either the first is good enough and you're done, or it wasn't and...

## Getting Started With Retrofit In Android

DevFeed: [Getting Started With Retrofit In Android](<https://devfeed.tech/articles/getting-started-with-retrofit-in-android-22808.md>)

Original publisher: [Read original article](<http://androidessence.com/getting-started-with-retrofit/>)

Author: Adam McNeilly

Published: 2016-10-13T00:00:00Z

Content type: tutorial

Language: en

Sources: [Android Essence](<https://devfeed.tech/sources/android-essence.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [Library](<https://devfeed.tech/topics/library.md>), [HTTP](<https://devfeed.tech/topics/http.md>), [Gson](<https://devfeed.tech/topics/gson.md>), [Java](<https://devfeed.tech/topics/java.md>), [JSON](<https://devfeed.tech/topics/json.md>), [Gradle](<https://devfeed.tech/topics/gradle.md>), [API](<https://devfeed.tech/topics/api.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [api](<https://devfeed.tech/tags/api.md>), [build](<https://devfeed.tech/tags/build.md>), [class](<https://devfeed.tech/tags/class.md>), [code](<https://devfeed.tech/tags/code.md>), [dependencies](<https://devfeed.tech/tags/dependencies.md>), [developer](<https://devfeed.tech/tags/developer.md>), [getting-started](<https://devfeed.tech/tags/getting-started.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [gson](<https://devfeed.tech/tags/gson.md>), [http](<https://devfeed.tech/tags/http.md>), [implement](<https://devfeed.tech/tags/implement.md>), [interface](<https://devfeed.tech/tags/interface.md>), [java](<https://devfeed.tech/tags/java.md>), [json](<https://devfeed.tech/tags/json.md>), [library](<https://devfeed.tech/tags/library.md>), [list](<https://devfeed.tech/tags/list.md>), [model](<https://devfeed.tech/tags/model.md>), [models](<https://devfeed.tech/tags/models.md>), [request](<https://devfeed.tech/tags/request.md>)

### AI overview

A beginner-to-intermediate tutorial explains how to create an Android application using Retrofit as an HTTP client. It covers Gradle dependencies, Gson JSON conversion, model classes, a service interface, API calls, and callbacks for completed requests.

### Source excerpt

As a new or intermediate Android developer, getting started with Retrofit, a popular HTTP client, can seem pretty daunting. However, using this library is not as scary as it sounds. Here are four easy steps to creating your first Retrofit application!

## Retrofit 2.0 Samples

DevFeed: [Retrofit 2.0 Samples](<https://devfeed.tech/articles/retrofit-2-0-samples-31827.md>)

Original publisher: [Read original article](<https://www.metachris.dev/2015/10/retrofit-2-samples/>)

Author: Chris Hager

Published: 2015-10-12T00:00:00Z

Content type: tutorial

Language: en

Sources: [Chris Hager](<https://devfeed.tech/sources/chris-hager.md>)

Topics: [Library](<https://devfeed.tech/topics/library.md>), [API](<https://devfeed.tech/topics/api.md>), [client library](<https://devfeed.tech/topics/client-library.md>), [Java](<https://devfeed.tech/topics/java.md>), [Gson](<https://devfeed.tech/topics/gson.md>), [HTTP](<https://devfeed.tech/topics/http.md>), [Android](<https://devfeed.tech/topics/android.md>), [Gradle](<https://devfeed.tech/topics/gradle.md>), [JSON](<https://devfeed.tech/topics/json.md>), [GitHub](<https://devfeed.tech/topics/github.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [api](<https://devfeed.tech/tags/api.md>), [articles](<https://devfeed.tech/tags/articles.md>), [client-library](<https://devfeed.tech/tags/client-library.md>), [github](<https://devfeed.tech/tags/github.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [gson](<https://devfeed.tech/tags/gson.md>), [java](<https://devfeed.tech/tags/java.md>), [json](<https://devfeed.tech/tags/json.md>), [retrofit](<https://devfeed.tech/tags/retrofit.md>)

### AI overview

A tutorial on using Retrofit 2.0 beta to consume HTTP APIs in Java and Android applications. It covers project setup with Gradle, JSON serialization with Gson, API client definitions, and sample GET and POST requests against httpbin.org.

### Source excerpt

This post is about using Retrofit 2.0 (beta) to consume HTTP based APIs. Retrofit is a great and popular API client library for Java (and by extension also for Android) developed by Square. Here's a few links to start things off: Retrofit Homepage Retrofit Source on Github Retrofit Javadoc Blog post about Retrofit 2.0 Source code with samples for this post is available on Github. Retrofit makes it easy to develop API clients by describing API endpoints and the results like this: