Write java class with nested Map to custom json format using Gson

What Java data structure can be used to serialize to the following Json which have a set of child objects? Example: { “John”: { “Type”: “Person”, “age”: 30, “Sean”: { …

How to deal with “cannot be cast to class” error – GSON JAVA

i am trying to write my list to jtable in abstract model and then its return to me this error. In my opinion it could be cause by list format? name and amount are in wrong place. This is my full error …

Conditionally serialise fields in Gson

I have two classes : Player and Match. Player has two fields, playerId and name while Match contains two Player objects and matchId too. When I serialise Player I do want the id and the name to appear …

GSON Integer to Boolean for Specific Fields

I’m dealing with an API that sends back integers (1=true, other=false) to represent booleans. I’ve seen this question and answer, but I need to be able to specify which field this should apply to, …

Store JSON data in Java

I want to learn JSON data storage in Java using Eclipse, so I googled a lot. I found JSON.simple and GSON. Are those a good choice? I went to Properties >> Java Build Path >> Add External …

How to handle a NumberFormatException with Gson in deserialization a JSON response

I’m reading a JSON response with Gson, which returns somtimes a NumberFormatException because an expected int value is set to an empty string. Now I’m wondering what’s the best way to handle this kind …