Skip to main content

Questions tagged [gson]

Gson is Google's open-source library for serializing and deserializing Java objects to/from JSON.

0 votes
1 answer
61 views

Gson serialize null only if value equals a specific pattern

Imagine I have an object that looks like this: @Getter @Setter static class MyObject { private String firstName; private String lastName; private long salary; } and then I have: private ...
Alp's user avatar
  • 51
0 votes
1 answer
55 views

Parsing JSON data with GSON into a model with JPA persistence

I need to parse JSON data received from an external API and persist it using JPA annotations. I used GSON as the parser, along with a TypeAdapter, because the model has the following simplified ...
J Robes's user avatar
  • 477
0 votes
0 answers
23 views

Expected BEGIN_OBJECT but was BEGIN_ARRAY KOTLIN code

Main.kt: package org.example import InfoJogo import com.google.gson.Gson import java.net.URI import java.net.http.HttpClient import java.net.http.HttpRequest import java.net.http.HttpResponse....
ALBERTO filho's user avatar
-1 votes
1 answer
41 views

How can I use Gson to unmarshal json into different class instances when data is a string-value map?

A brokerage is returning data from a GET for the query "MSFT,AAPL,XYZZ": { "MSFT": { "assetMainType": "EQUITY", "assetSubType": "COE&...
John Churchill's user avatar
0 votes
0 answers
40 views

How solve java.lang.NoSuchMethodError for Gson when trying to implement Spotify API in SpringBoot project

Getting below error when trying to run my SpringBoot project which implements the SpotifyAPI from MichaelTheLin: java.lang.NoSuchMethodError: 'com.google.gson.JsonElement com.google.gson.JsonParser....
AlexNazemi's user avatar
0 votes
0 answers
24 views

Android Studio Get data from a user input searched API

I am using Android Studio and I am trying to make it so that whatever the user types into the searchview, it will be passed into the API call as a parameter and then return all the data based on each ...
CAM3R0N's user avatar
0 votes
1 answer
55 views

Loading Maven libraries into GUI project

What is the correct way to load and use a library with Maven? I am trying to use the Gson library for my GUI project, but doing so I get errors. These are my steps: Creating the Maven project works ...
Socrates's user avatar
  • 9,336
0 votes
0 answers
42 views

JSON Syntax Exception when parsing String containing JSON Array using TypeToken via GSON

Am having trouble parsing String containing a JSON array as a List using TypeToken via GSON in my Kotlin program. dependencies section inside gradle.build.kts: dependencies { implementation("...
PacificNW_Lover's user avatar
0 votes
0 answers
45 views

LocalDate to JsonObject serialization (Expected BEGIN_OBJECT but was STRING com.google.gson.JsonSyntaxException)

I am having a dateField which is in this format and of type java.time.LocalDate - "dateField":"2024-06-11" in one of the classes. Class is "ObjectClass" I am trying to ...
user2868864's user avatar
0 votes
1 answer
11 views

Name expected issue - convert Json to class

I am trying to convert Json string into instance of a class. There is 'Name expected' error as below image. I could not find any solution from Googling. I added below dependency into build.gradle(app)...
Denis Jung's user avatar
1 vote
2 answers
54 views

How to convert response to my class object?

I am trying to convert response string into a java object (of Temp Class) for further manipulating but I get below error: Exception in thread "main" com.google.gson.JsonSyntaxException: ...
Lyrk's user avatar
  • 1,980
0 votes
3 answers
40 views

Why to use TypeToken for fromJson function?

I have a mapper like inline fun <reified DTO_TYPE, reified TYPE> DTO_TYPE.toDomainLayer(): TYPE { val gson = Gson() val strJson = gson.toJson(this) val type = object: TypeToken<...
Parth Malaviya's user avatar
0 votes
1 answer
52 views

Server response with null value

Hello i'm creating a rest server using ktor in my android application. It works really well but when i do a call i receive all the data but i don't get null data. What should i do to receive them. ...
alpheonix's user avatar
  • 321
0 votes
0 answers
38 views

Using Volley instead of Gson and OkHttpClient to request service:

I'm relatively new to API integration and would appreciate some guidance on transitioning my code from using OkHttpClient and Gson to using Volley and JSONObject for API requests. Initially, I ...
Sthesh's user avatar
  • 1
0 votes
1 answer
41 views

Can't load items from mutableStateOf(ListOf) onto composable Jetpack Compose

I'm making an android app with Kotlin and compose and I'm using GSON to parse some JSON that I retrieve from an API. The data is then put into a list and returned from the function. I have a ...
George Clensy's user avatar

15 30 50 per page
1
2 3 4 5
656