All Questions
6,012
questions
0
votes
1
answer
64
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 ...
0
votes
1
answer
58
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 ...
-1
votes
0
answers
25
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....
0
votes
0
answers
43
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("...
0
votes
0
answers
46
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
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: ...
0
votes
0
answers
52
views
com.google.gson.stream.MalformedJsonException | Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $
I'm encountering the following problem when sending an API request on my Android 10 device. The response to the request I sent to the API returns as follows:
Actually, I am facing a crash issue ...
0
votes
1
answer
82
views
Why does the JsonWriter throw an Incomplete document exception in GSON?
I want to send json over a socket stream but I constantly encounter this error, when closing the connection and I have no idea why.
I am trying to close a JsonWriter and I get an IOException even ...
1
vote
0
answers
45
views
Springboot using Gson serialization and @Since/@Until annotations
I have a springboot application (REST API), and I've configured GSON to be my default serializer/deserializer instead of Jackson. I already have versioned models, using @Since and @Until annotations, ...
0
votes
1
answer
52
views
Handling non-constructor properties when converting Kotlin data classes from JSON
I'm working on a project where we need to serialize/deserialize Kotlin data classes to/from JSON using the GSON library. The class I am working on looks like:
data class Request(val parent_identifier: ...
1
vote
1
answer
95
views
Check if a field exists in JsonObject using gson in java
I have a following JSON structure
{
"entity": {
"bsid": "8452",
"name": "Name limited",
"contact": "CONTACT",
&...
-2
votes
1
answer
145
views
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 67 path $.data [duplicate]
I have this method and I have a problem with gson in code :
public static CmsUser validateTokenCms(String token, RestTemplate restTemplate, PropertyCommonConfig propertyCommonConfig) {
...
-1
votes
1
answer
32
views
Dynamically generated JSONObject null values are converted to string after saving and retrieving it from MySQL DB
I am getting a JSON object from google maps and saving to MySQL DB using JdbcTemplate in a longBLOB data type. The format of JSON before saving is:-
{"circle_bound":["-109....
0
votes
2
answers
49
views
Android, A Gson wipes data inside ArrayList<HashMap<String,Uri>>
I'm tried to save ArrayList<HashMap<String,Uri>> into json using Gson, but when i read data from json , im noticed that Gson just wiped out data inside HashMaps.
I want to that Gson doesn'...
0
votes
1
answer
47
views
Nested classes in Gson
I am new to Gson and I have a json response from an api that is nested. I created nested classes -
public class GsOrgIds {
public GsOrgIdsData data;
public String msg;
public int ...