Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
16 views

KSP generated Moshi adapters not used in combination with Retrofit in a kotlin based SpringBoot application

I fail to get serialization to work inside a small springboot application. Read a couple of issues, guides and documentation on this. But still fail to get this to work. I use moshi for JSON ...
arkascha's user avatar
  • 42.7k
0 votes
0 answers
46 views

Could not find com.squareup.moshi:moshi-kotlin-reflect:1.15.1

I'm currently facing a build failure in my Android project that uses Kotlin DSL with a version.toml file for dependency management. During the build process, I encounter multiple failures related to ...
Fátima Ramone's user avatar
1 vote
0 answers
48 views

Retrofit OkHttp with Moshi: Gzip Encoding Error

I'm using Retrofit with OkHttp and Moshi. I have to add the "Accept-Encoding":"gzip, deflate, br" header myself. But OkHttp adds its own "Accept-Encoding" header. Due to ...
Mustafa Tatarhan's user avatar
0 votes
0 answers
42 views

Moshi and annotation @field:Json(name="some_field") and Json(name="some_field")

After upgrading retrofit to version 2.11.0 and moshi to version 1.15.1, everything broke for me. Previously, I used the annotation @field:Json(name="some_field") in models. But now for ...
Anton111111's user avatar
1 vote
1 answer
417 views

Prevent proguard/r8 from removing Kotlin synthetic default constructor

I'm using moshi which accesses the Kotlin default constructor of a class by reflection. The class looks like this: @JsonClass(generateAdapter = true) data class AClassName( val threadId: String, ...
der_Fidelis's user avatar
  • 1,515
0 votes
0 answers
35 views

Using Moshi in an extension function or injecting it via DI in Android

In Android, I am using an extension function to map a failed network response to my sealed ErrorResponse class. @JsonClass(generateAdapter = true) data class ErrorResponse( @Json(name = "code&...
tzegian's user avatar
  • 587
0 votes
0 answers
29 views

How to pass dynamic meta data along with fromJson()?

I have a problem for which I am sure there is a solution. I just can't find it. I am parsing a Json using moshi. Some custom adapters have to filter/transform the data based on some meta data that ...
Tobi's user avatar
  • 47
1 vote
1 answer
430 views

Using kotlin kotlinx serialization with generics

Hi everyone I have the following code that I use to serialize into json strings to store in shared preferences interface Serializer { public fun <T> serialize(data: T, type: Class<T>): ...
Abdelrhman Talat's user avatar
1 vote
1 answer
80 views

Map deserialization with moshi and retrofit

I have the below json response {"page":2, "results":{ "0":{ "id":1, "name":"Jane" }, "1":{ "...
Raji A C's user avatar
  • 2,351
1 vote
0 answers
29 views

Why is the "invisible" field null in GetStream.io dashboard despite setting it to false when querying users?

I'm encountering an issue with GetStream.io while querying users. Despite explicitly setting the "invisible" field to false in the user object during the query, the field remains null in the ...
Xynapz1 Test's user avatar
1 vote
0 answers
88 views

How to create a custom Moshi JsonAdapter that returns a Map?

I'm using an API that returns the following data: { "ad": "Andorra", "ae": "United Arab Emirates", "af": "Afghanistan", &...
Daniel Bertoldi's user avatar
0 votes
1 answer
169 views

How to deserialize JSON enums in case insensitive way using Moshi library?

The sample source JSON object is defined as: { "source": "WIFI" } However, the value can be lowercase and when it does, I get following error. Exception in thread "main&...
Hossain Khan's user avatar
  • 6,452
0 votes
2 answers
366 views

Android Moshi Json Converter Causes kotlin.reflect.jvm.internal.KotlinReflectionInternalError

I am using Moshi as Json Converter with Retrofit in Android. When I set minifyEnabled to true, For some API calls it works, but for others it throws this Error: This callable does not support a ...
Omar Assidi's user avatar
2 votes
0 answers
72 views

How tu suppress warnings issued by javac task

Recent version of Moshi (1.15.0) is issuing a warning Kapt support in Moshi Kotlin Code Gen is deprecated and will be removed in 2.0. Please migrate to KSP. https://github.com/square/moshi#codegen&...
mar3kk's user avatar
  • 1,936
0 votes
0 answers
101 views

Not finding @com.squareup.moshi.Json <fields>; rule in official moshi proguard file. Am I missing something?

Given a simple data class import com.squareup.moshi.Json import com.squareup.moshi.JsonClass @JsonClass(generateAdapter = true) data class User( @field:Json(name = "name") val name: ...
Cheok Yan Cheng's user avatar
1 vote
1 answer
183 views

How do I deserialize a string within a moshi object as its own moshi object?

I have a JSON object (that I can't change) that passes some data like so: { "title": "foo", "actions": "[ { \"label\": \"Hello\" ...
der_Fidelis's user avatar
  • 1,515
0 votes
1 answer
777 views

Android How to convert this JSON into object of data class with Moshi Kotlin?

There is a Json file which is put to val fileInString: String. This string looks simplistically like this. { "groups": 2, "group1": [ { "word": "test11", "...
Tropic's user avatar
  • 3
0 votes
0 answers
83 views

Kotlin data class coming from serialized json become a LinkedHashTreeMap

So, i have an Android Room entity that have a properties which is a list of a data class. Like this: @ColumnInfo(name = "titles") val titles: List<AnimeTitleEntity>, And I'm ...
lelestacia's user avatar
0 votes
2 answers
508 views

Moshi Json name annotation property not working

I'm trying to use @Json(name = "Result") property to change the field name and it's not working. The result is always null from retrofit response, but if I use the actual "Result" ...
IAmNotARobot's user avatar
  • 1,425
1 vote
2 answers
300 views

Cannot parse a list using Moshi

With all the posts out there about Moshi and people's confusion (including my own) about how to parse a list, I can't believe that this is this difficult. I have an object that has two nested lists. I ...
AndroidDev's user avatar
  • 21.2k
0 votes
0 answers
78 views

Why my MoshiConverterFactory is slower then GsonConverterFactory?

when I post an api, it took too many time to response Here is my retrofit builder: fun provideRetrofit(baseUrl: String): Retrofit = Retrofit.Builder() .client(provideOkhttpClient()) ....
aile's user avatar
  • 1
1 vote
0 answers
110 views

Add custom adapter to moshi

I have an interface Data with a function called toData(). Different objects inherits from this Data. Now I wrote an adapter which transform the result of toData() into an string My custom adapter ...
kuzdu's user avatar
  • 7,514
0 votes
1 answer
97 views

Parse json with moshi where one of the fields is polymorphic

I want to parse the following JSON API response into the list of objects. As you can see, the field "record" is polymorphic. [ { "t_id": "638975A6-3E5A-4D38-82A0-...
gdrt's user avatar
  • 3,295
-1 votes
1 answer
123 views

My API call isn't working and my app return me "Expected BEGIN_ARRAY but was BEGIN_OBJECT at path $ solution"

Hi I'm currently working on a android app (android studio) for a class and i need to make API calls i followed some tutorials (android developper and some on YT). From these tutorial i learned to use ...
Zares's user avatar
  • 1
1 vote
0 answers
133 views

Moshi Json - Decompiled code still shows annotated name

I am trying to enable code obfuscation in my android project. I am using moshi for json operations. I am having a problem with release apk file. When I use a decompiler the @JsonClass(generateAdapter =...
KAPLANDROID's user avatar
  • 1,109
1 vote
1 answer
69 views

java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT in my weather App

I am trying to make an API call to open-meteo.com API each time I run my app I get the an error: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT I have checked several ...
robson idongesit samuel's user avatar
1 vote
1 answer
2k views

Using Moshi in Kotlin (Android), Moshi.adapter() signatures seem to differ from the docs

My build.gradle dependencies (for a non-main Android Studio module): dependencies { implementation 'androidx.core:core-ktx:1.12.0' implementation 'com.squareup.moshi:moshi-kotlin:1.14.0' ...
LyrePyre's user avatar
  • 422
0 votes
1 answer
179 views

Moshi - Unable to create converter for enum class for gradle 8 and upwards

An error occurs during runtime, after updating to gradle 8.1.1 from 7.4.2: "java.lang.IllegalArgumentException: Unable to create converter for class $myEnumClass Caused by: java.lang....
Nikos M's user avatar
  • 194
0 votes
1 answer
634 views

Enable R8 when using moshi-kotlin-codegen

I am trying to enable R8 for my project : https://github.com/alirezaeiii/TMDb-Compose-Playground buildTypes { release { minifyEnabled true shrinkResources true ...
Ali's user avatar
  • 9,994
0 votes
1 answer
44 views

Android AWS DynamoDB: Using AWS mapper.save with Moshi

I use an AWS DynamoDB database to store data. I'm saving a "CommunityUser" object, which class looks as follows: class CommunityUser { @get:DynamoDBHashKey(attributeName = AWSTables....
Diego Perez's user avatar
  • 2,802
1 vote
1 answer
406 views

Moshi: Problems serializing List<MyClass>

I'm migrating Gson to Moshi, and I'm having problems serializing List<object>. I have no problem with "plain" objects, but with Lists. I have a class ImageDTO (including a Moshi ...
Diego Perez's user avatar
  • 2,802
0 votes
1 answer
2k views

Android Kotlin Moshi: Custom adapter for Moshi not working

I have a json than can have two possible values {"school.name": "A school name"} or {"name": "Another school name"} And I have a common "College" ...
Diego Perez's user avatar
  • 2,802
1 vote
1 answer
613 views

Moshi adapter to ignore bad elements from a polymorphic list

I have a polymorphic list of contents sent by the backend. I use PolymorphicJsonAdapterFactory to parse it to Kotlin objects. It all works fine. When the backend sends an element with an unknown type ...
Camilo Sierra Rodriguez's user avatar
2 votes
1 answer
1k views

Moshi LinkedHashTreeMap class cast exception with Proguard

When proguard is enabled, after an API call with retrofit, I recieve a list of LinkedHashMapTree that causes this error: java.lang.ClassCastException: com.squareup.moshi.LinkedHashTreeMap cannot be ...
TabascoLosco's user avatar
0 votes
0 answers
58 views

API call providing null response

Note: This is done in Kotlin in Android studio. Here is the documentation of my API: https://www.api-football.com/documentation-v3#tag/Teams/operation/get-teams I am trying to make a simple call to ...
Dereck Helms's user avatar
0 votes
1 answer
351 views

PUT with Retrofit2 using Kotlin fails with 415 Server using Reqeust @Body Object in Android

I want to call a login api that I've been using for over 6 years, so I know the API is good. It is already in production, and used for our website, iOS app, and Android app. My current project is ...
jonathan3087's user avatar
0 votes
2 answers
636 views

Moshi: How to Deserialize JSON with a mix of fixed and dynamic properties

For a JSON like this consider the properties other than attributes are dynamic: "records": [ { "attributes": { "type": "...", "url": ...
Gopal S Akshintala's user avatar
1 vote
2 answers
182 views

Getting Expected BEGIN_OBJECT but was BEGIN_ARRAY error if API returns the empty array Instead of list in kotlin android moshi

Getting error while parsing the API response using Moshi. Sample Reponses: Expected API response {"itemsValues":[{"Id":"567"},{"Id":"678"}]} If list ...
Android Dev's user avatar
-1 votes
1 answer
645 views

How to convert a JSON array of mixed types using moshi and kotlin

Iam unable to convert this Json, keep getting the following error: com.squareup.moshi.JsonDataException: Expected a string but was BEGIN_OBJECT at path {"summary": { "rows": [ ...
Eknath's user avatar
  • 164
1 vote
0 answers
410 views

Converting Json to data class inside sealed class in Kotlin

I have this API Response { "id": 45, "name": "Bill", "status": "Alive", } the status prop can have three possible results: Alive, Dead and ...
Eduardo Martins's user avatar
15 votes
6 answers
10k views

R8 full mode throws class cast exception AGP 8.0

I recently upgraded to Android Studio Flamingo and AGP 8.0 My production builds with minfiy and shrinkResources enabled, doesn't allow retrofit to make calls. This is the error thrown. java.lang....
Abhishek AN's user avatar
0 votes
1 answer
2k views

How to serialize a value class with moshi so it just return it's value

I hava a value classin my android project (kotlin) and I want to parse a object, that contains this value class as type for a attribute, to json. Let's say this is my value class: @JsonClass(...
Thomas Cirksena's user avatar
0 votes
2 answers
907 views

Moshi equivalent to Gson.toJson

I'm new to Moshi and I was thinking to implement it to replace my Gson lib. Can't figure out how exactly I can convert a model class into a string in JSON format. My model is UiGeneralCategory I have ...
Vlad.mir's user avatar
  • 695
0 votes
1 answer
578 views

Android Moshi unable to apply custom adapter

My use case is that in data classes wherever I have used Boolean as type, in JSON that can either comes as double quote string ("true") or normal boolean (true) Earlier I was using Gson &...
Ujjwal Kumar Maharana's user avatar
-1 votes
1 answer
1k views

Retrofit android Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $

I am new to Retrofit and I am having a weird problem. I am getting the following error --> Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $ However when I hit the endpoint with ...
user1743524's user avatar
2 votes
0 answers
42 views

How to handle rubbish data in Moshi

I do have a json: { "items":[ { "id":"0000301553526", "values":{ "name":{ "value":{ ...
Unii's user avatar
  • 1,617
1 vote
1 answer
499 views

Kotlin Moshi adapter return null when library throw JsonDataException

We are using old backend. Sometimes list of objects is returned when contract says it should be text (and other ways). How/where can we handle JsonDataException Expected a string but was BEGIN_OBJECT ...
Unii's user avatar
  • 1,617
0 votes
0 answers
71 views

How to parse a class that extends from Arraylist with Moshi

I'm new with Moshi and I'm trying to parse the data, with Retrofit, from one class that extends an Arraylist of items and I'm getting this error: com.squareup.moshi.JsonDataException: Expected ...
S.P.'s user avatar
  • 2,544
2 votes
1 answer
1k views

Parse JSON string to a list of objects in Kotlin Android (MOSHI?)

In my app, I'm using Retrofit to get the data from API (with flights data). I want to obatin List< Itinerary > from JSON, but the problem is that it is badly formatted, and I'm getting the ...
deja's user avatar
  • 486
1 vote
0 answers
711 views

com.squareup.moshi.JsonDataException: Required value 'access_token' missing at $

I try to do post request using retrofit and I use moshi to serialize but I'm not very well versed in these matters. And I am facing such an error, what is the reason for this? error E/AndroidRuntime: ...
NewPartizal's user avatar
  • 1,094

1
2 3 4 5
11