Questions tagged [gson]

Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object. Gson can work with arbitrary Java objects including pre-existing objects that you do not have source-code of.

Filter by
Sorted by
Tagged with
0 votes
0 answers
34 views

Resource manager code improvement

So I'm making a utility class to find resources and read them as JSON objects using the GSON library, the code below is working good but I don't really know how good it is, so I would like to get ...
user avatar
  • 1
1 vote
1 answer
73 views

Generic Class for a GSON LinkedHashMap

I originally posted this on Stack overflow and was told to post it here, so here it is. Here's the stack overflow question: https://stackoverflow.com/questions/66528393/generic-class-for-a-gson-...
user avatar
3 votes
2 answers
113 views

Code for saving / loading a class object

As I was advised, I broke my code into 2 classes. Could you take a look at the repository class and report what problems this code has ...
user avatar
  • 407
0 votes
0 answers
40 views

Templated JSON parsing methods that work with an element or elements array

Consider the following two Java methods. The first takes a JSON string representing one element, the second representing multiple elements. gson.fromJson() can be ...
user avatar
  • 1
3 votes
2 answers
5k views

Call multiple asynchronous HTTP requests and wait for the result

I have a Repository class which looks like this: ...
user avatar
  • 133
0 votes
1 answer
51 views

Get latest jsons with respect to [version and name] key in subjson in java

This is the json ...
user avatar
7 votes
2 answers
769 views

Parsing and creating JSON packets

For several of my pet projects, I have had to interpret and/or send JSON WebSocket or HTTP responses in Java. I did some research and picked the library GSON to use. In each project, I have ...
user avatar
1 vote
1 answer
103 views

Parsing different json to one model

I have several json models which represent same logic model. e.g: {"title":"title1","years":"31"} and {"name":"title1","age":31} ...
user avatar
  • 245
1 vote
0 answers
41 views

Java Market Summary - JSON

I am writing a java program that will print current market values from a websites api. I used gson to parse the incoming json and Timer to run it every 5 minutes. I was wondering if this was the best ...
user avatar
  • 141
2 votes
1 answer
104 views

Improvements for ugly reflection

I have a project that uses a library to save serialized objects in items and loads them again, when needed. To do the de-/serialization, this library uses Gson. Due to how Gson works and how the ...
user avatar
  • 628
2 votes
1 answer
650 views

Gson to Model containing several return types for one key

i just had a problem converting the JSON from Phillips Hue Lights (Response) to a Model. Since it may contain several "unknown" keys in success and/or may contain just a String for success i had to ...
user avatar
  • 163
5 votes
1 answer
1k views

Keep parsing JSON response until a field becomes false using GSON

I have JSON which is coming by executing a URL. I want to store all the value of id field in a List<String> by parsing ...
user avatar
  • 2,077
2 votes
1 answer
1k views

Class for serializing generic gson objects

I realized I had just created two classes that were virtually identical for simply saving objects to their own json files, so I've attempted to make it more generic. My only noticeable problem is ...
user avatar
1 vote
1 answer
2k views

Google Maps coordinations JSON to object

I am trying to write a parser from JSON data which I get from Google requesting coordinates of a city, which will create my specified object structure. For parsing, I've written a custom ...
user avatar
  • 111
5 votes
1 answer
88 views

Google Gson - adding arrays to a List

I want to make sure if it's good. Maybe there is another better solution. ...
user avatar
  • 185
3 votes
1 answer
10k views

Recursively parsing JSON response using GSON

I have a URL which I am executing it and it is returning the below string as a JSON response. I am using GSON to parse JSON. In the below JSON, "resourceId" ...
user avatar
  • 2,077
2 votes
1 answer
2k views

GSON parsing - nested classes or not

Today I was trying GSON after a while and went to the YQL console to run this query: ...
user avatar