9,830 questions
0
votes
3
answers
111
views
How to convert a JSON array to a Java list and handle JSON null values that's going to an int varible?
TL;DR: when my JSON array is converted to a list of Java objects, the null values in the JSON string is converted to 0 instead of staying as null.
I want to keep them as null in the Java object.
I ...
0
votes
0
answers
59
views
caching a serialized immutable object in Jackson
Use case
Say I have an HTTP endpoint that constructs an immutable object then sends that immutable object to multiple sinks. Maybe I send it to a couple of message brokers, other HTTP endpoints, a ...
0
votes
1
answer
68
views
Using Gson fromJson() to Create Instances of Java Classes from JSON With Dynnamic @SerializedName Annotation Value
I have this JSON snippet. My problem is the key under transactions{} in this example it is set to "Request ID 000002" However this is part of a response to an API request and that value ...
2
votes
1
answer
191
views
Why can't I "requires com.google.gson" when using gson-2.13.1.jar in Eclipse 2024-12 without having to rename the file?
Hardware/Software setup:
IDE: Eclipse IDE Version 2024-12 (4.34.0)
JDK: jdk-21
OS: Windows 11 Pro 24H2
CPU: 12th Gen Intel(R) Core(TM) i5-12600KF
Background/Project Configuration
I created a ...
0
votes
1
answer
52
views
Gson custom serializer for PublicKey is never called [duplicate]
Here is the serializer for java.security.PublicKey:
public class PublicKeySerializer implements JsonSerializer<PublicKey> {
@Override
public JsonElement serialize(PublicKey key, Type ...
0
votes
0
answers
47
views
Type com.google.gson.FieldNamingPolicy$5 is defined multiple times
I'm working on a C# native android project using net8.0-android34.0 as framework version and one of the projects in the solution imports those android libraries:
<AndroidLibrary Update="Jars\...
2
votes
0
answers
53
views
Lazy de-serialization of a JSON array as a Stream<T> [duplicate]
Consider I have a large (potentially infinite) array of JSON objects:
[
{
"id": 41,
"name": "foo"
},
{
"id": 42,
&...
0
votes
3
answers
71
views
Gson JsonArray find Object by key
How to get a JsonObject out of JsonArray by JsonObject key value?
[{key: "one", value: "beach"}, {key: "two", value:"sky"}]
In Javascript I would do arr.filter(...
1
vote
1
answer
65
views
kotlin why multiple elvis operator didn't return default value but null
I have a data class:
data class Example(
@SerializedName("id")
val id: String,
@SerializedName("url")
val url: String,
@SerializedName("more")
val ...
0
votes
0
answers
122
views
In Android, how do you serialize a mutable state data type using Gson?
As the title states I'm trying to serialize a mutable state data type into a JSON format using the Gson library so that it can be saved into a file. However, the application crashes every time I do so....
1
vote
1
answer
381
views
Spring boot, azure-functions-java-worker and GSON lib compatibility Issue
I have upgraded my java azure function dependencies from Spring boot 3.3.0 -> spring boot 3.4.0 and using the below dependencies.
com.microsoft.azure.functions:azure-functions-java-library:3.1.0
...
0
votes
0
answers
41
views
Gson Custom Deserializer For Nested JSON [duplicate]
I have the below JSON. I want to be able to store it in an instance of a Java class. I think that I need a custom deserializer to do so. I have working code that can create JsonObject of the top ...
0
votes
0
answers
100
views
Caused by: java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to com.xxx.core.model.vo.circle.Profile
I'm getting an error:
java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to Profile:
Below is the method where we are getting the exception, and we have tried ...
0
votes
2
answers
57
views
Why com.google.code.gson package can not convert value of java.sql.Timestamp correctly from a json string sent from Postman to Tomcat?
What I do?
I sent a GET request from Postman to Tomcat v9.0 with following data.
{
"diaryId":2,
"userId":2,
"createTimestamp":"2022-05-05 12:00:00", ...
0
votes
0
answers
45
views
Android - Deserialize specific object in data class response with Gson
I have this example json:
{
"base": {
"data": "{\"ids\":[\"first-v1\",\"second-v2\"],\"version\":\"1\",\"...
1
vote
2
answers
64
views
How to change root of JSON response before cast to typed entity?
Task
The remote server returns a response with a body:
{
done: true,
response: {
result: {
// data
}
}
}
In case of an error, a response with 200 status and a ...
-5
votes
1
answer
136
views
How to deserialize from JSON array in quotes [duplicate]
Using java and GSON, I want to deserialize my POJO class
@Data
public class Book {
@SerializedName("id")
private String id;
@SerializedName("tags")
...
0
votes
1
answer
88
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 ...
0
votes
0
answers
195
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....
0
votes
1
answer
143
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 ...
0
votes
0
answers
97
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 ...
1
vote
2
answers
294
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: ...
0
votes
1
answer
184
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.
...
0
votes
1
answer
63
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 ...
0
votes
1
answer
87
views
Fetching Api returns Array of Arrays instead Array of Objects using Retrofit and Gson
Recently I have been working on project which includes working with API.
I have checked it in Postman and I am sure that its response is an Array of Objects but when tried to use it I faced Expected ...