Category : gson

I’m not sure if polymorphic is the right term to use so my apologies. I’m working with the following API: Request body: { "user_id": "user_id", "command": "submit_document", } Response: { "result": "success", "code": 200, "status": "ok", "screen": "documents_rejected", // This is unique for different `data` "next_screen": "", "message": "Successful", "data": { // `data` is always ..

Read more

/* This is my json file */ { "firstname": [ "rohit", "sagar", "sandeep", "rahul", "sweta", "priya" ] } /* MainActivity.java */ package com.example.gsonflow; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import com.google.gson.Gson; import java.io.InputStream; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Gson gson = new Gson(); InputStream data = this.getResources().openRawResource(R.raw.safas); String ..

Read more

After use implementation ‘com.google.firebase:firebase-firestore-ktx:24.0.0’ i have the message unresolved dependence com.google.gson.Gson, if i try to run the application it work’s fine, but i don’t have suggest of Gson into android studio, and have a red underline like an error. I’m tryed implementation ‘com.google.code.gson:gson:2.8.9’ and also don’t works. I’m using kotlin, is all dependences updated. Source: ..

Read more

Before you mark it as duplicate, I already seen similar questions and none of the solutions work when I try them! This is how I tried it based on the answers in the "solutions": Saving: val gson = Gson() val hiddenUserList: ArrayList<HiddenUserModel> = ArrayList() hiddenUserList.add(HiddenUserModel(777L, "steveee")) hiddenUserList.add(HiddenUserModel(888L, "donbimbo")) val json = gson.toJson(hiddenUserList) prefs.edit().putString("hiddenUser", json).apply() So ..

Read more

my response is something starts with some string which is not required and not in our control. "[Hit(json={"offerId":"something"} for which I am unable to convert with the below gson.fromJson(result.toString(), DataList::class.java) I am getting java.lang.IllegalStateException: how can we handle this with out request the API team to change the response? Source: Android..

Read more

I get this error when I use Multipart Form and my json format is valid. I don’t get this when I use FormUrlEncoded. My Service Generator Code that returns the retrofit: object ServiceGenerator { private val client = OkHttpClient.Builder().build() private val retrofit = Retrofit.Builder() .baseUrl("https://test23-app.ir/api/") .addConverterFactory(GsonConverterFactory.create()) .client(client) .build() fun <T> buildService(service: Class<T>) : T { ..

Read more

I am very new with android and GSON library and I have a problem trying to get a GSON model subclass. I create a GSON object Indicators with a subclass Values and get methods using predefined OKhttp Profiler builder: import java.util.List; import com.google.gson.annotations.SerializedName; public class Indicators { @SerializedName("indicator") public Indicator indicator; public static class Values ..

Read more

I’m building an app with Kotlin in Android Studio and I am trying to implement GsonBuilder but I’m getting an Unresolved reference: GsonBuilder. However, I have already added the dependency to the .gradle file using implementation ‘com.google.code.gson:gson:2.8.9’ and I imported it into the page with import com.google.gson.Gson. Below is the implementation in my code: client.newCall(request).enqueue(object: ..

Read more