Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6588673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:04:38+00:00 2026-05-25T17:04:38+00:00

I want to parse a JSON object using GSON. Everything seems to work fine

  • 0

I want to parse a JSON object using GSON. Everything seems to work fine but when I’m trying to parse a more “complexed” object I’m getting a deserialization error. The object I’m trying to parse contains some primitives, a stack and a vector collection.

Is it possible that the stack\vector causing this problem? can I somehow over come this?

The Error:

Exception in thread "AWT-EventQueue-0" com.google.gson.JsonParseException: The JsonDeserializer com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter@4e76fba0 failed to deserialize json object [{"name_":"Human","points_":1,"alive_":true,"id_":0,"cssStyleClass":"pressed_p1"},{"name_":"Human","points_":0,"alive_":true,"id_":1,"cssStyleClass":"pressed_p2"}] given the type java.util.Vector<entities.Player>
    at com.google.gson.JsonDeserializerExceptionWrapper.deserialize(JsonDeserializerExceptionWrapper.java:64)
    at com.google.gson.JsonDeserializationVisitor.invokeCustomDeserializer(JsonDeserializationVisitor.java:92)
    at com.google.gson.JsonObjectDeserializationVisitor.visitFieldUsingCustomHandler(JsonObjectDeserializationVisitor.java:117)
    at com.google.gson.ReflectingFieldNavigator.visitFieldsReflectively(ReflectingFieldNavigator.java:63)
    at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:120)
    at com.google.gson.JsonDeserializationContextDefault.fromJsonObject(JsonDeserializationContextDefault.java:76)
    at com.google.gson.JsonDeserializationContextDefault.deserialize(JsonDeserializationContextDefault.java:54)

Request Code

Gson json = new Gson();
Multiplayer result = json.fromJson(answer.toString(), Multiplayer.class);

Code On Servlet

Gson gson = new Gson();
Multiplayer game = (Multiplayer)getServletContext().getAttribute("OnlineGame");
String responseStr = gson.toJson(game);

response.setContentType("application/json;charset=UTF-8");
out.write(responseStr);

String from toString()

{serializeNulls:false,serializers:{mapForTypeHierarchy:{Map:MapTypeAdapter,Collection:com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter@596e1fb1,InetAddress:com.google.gson.DefaultTypeAdapters$DefaultInetAddressAdapter@4ce2cb55,Enum:EnumTypeAdapter},map:{Integer:IntegerTypeAdapter,URI:UriTypeAdapter,UUID:UuidTypeAdapter,BigInteger:BigIntegerTypeAdapter,URL:UrlTypeAdapter,Short:ShortTypeAdapter,Time:com.google.gson.DefaultTypeAdapters$DefaultTimeTypeAdapter@16bdb503,byte:ByteTypeAdapter,short:ShortTypeAdapter,Number:NumberTypeAdapter,double:com.google.gson.DefaultTypeAdapters$DoubleSerializer@b6e39f,GregorianCalendar:GregorianCalendarTypeAdapter,Calendar:GregorianCalendarTypeAdapter,Byte:ByteTypeAdapter,StringBuilder:StringBuilderTypeAdapter,Float:com.google.gson.DefaultTypeAdapters$FloatSerializer@6719dc16,Locale:LocaleTypeAdapter,StringBuffer:StringBufferTypeAdapter,Date:DefaultDateTypeAdapter(SimpleDateFormat),Character:CharacterTypeAdapter,float:com.google.gson.DefaultTypeAdapters$FloatSerializer@6719dc16,BigDecimal:BigDecimalTypeAdapter,Boolean:BooleanTypeAdapter,boolean:BooleanTypeAdapter,String:StringTypeAdapter,Timestamp:DefaultDateTypeAdapter(SimpleDateFormat),int:IntegerTypeAdapter,long:LongSerializer,Date:com.google.gson.DefaultTypeAdapters$DefaultJavaSqlDateTypeAdapter@52c05d3b,char:CharacterTypeAdapter,Double:com.google.gson.DefaultTypeAdapters$DoubleSerializer@b6e39f,Long:LongSerializer},deserializers:{mapForTypeHierarchy:{Map:MapTypeAdapter,Collection:com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter@596e1fb1,InetAddress:com.google.gson.DefaultTypeAdapters$DefaultInetAddressAdapter@4ce2cb55,Enum:EnumTypeAdapter},map:{Integer:IntegerTypeAdapter,URI:UriTypeAdapter,UUID:UuidTypeAdapter,BigInteger:BigIntegerTypeAdapter,URL:UrlTypeAdapter,Short:ShortTypeAdapter,byte:ByteTypeAdapter,Time:com.google.gson.DefaultTypeAdapters$DefaultTimeTypeAdapter@16bdb503,short:ShortTypeAdapter,Number:NumberTypeAdapter,double:DoubleDeserializer,Byte:ByteTypeAdapter,Calendar:GregorianCalendarTypeAdapter,GregorianCalendar:GregorianCalendarTypeAdapter,StringBuilder:StringBuilderTypeAdapter,Float:FloatDeserializer,Locale:LocaleTypeAdapter,StringBuffer:StringBufferTypeAdapter,Date:DefaultDateTypeAdapter(SimpleDateFormat),Character:CharacterTypeAdapter,float:FloatDeserializer,BigDecimal:BigDecimalTypeAdapter,Boolean:BooleanTypeAdapter,boolean:BooleanTypeAdapter,String:StringTypeAdapter,Timestamp:com.google.gson.DefaultTypeAdapters$DefaultTimestampDeserializer@5328f6ee,int:IntegerTypeAdapter,long:LongDeserializer,Date:com.google.gson.DefaultTypeAdapters$DefaultJavaSqlDateTypeAdapter@52c05d3b,char:CharacterTypeAdapter,Double:DoubleDeserializer,Long:LongDeserializer},instanceCreators:{mapForTypeHierarchy:{SortedSet:DefaultConstructorCreator,Set:DefaultConstructorCreator,Queue:DefaultConstructorCreator,Collection:DefaultConstructorCreator,Map:DefaultConstructorCreator},map:{}}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:04:39+00:00Added an answer on May 25, 2026 at 5:04 pm

    I recommend you to use an array Player[] instead of the generic collection Vector<Player>. It’s not easy to use Java generics for serializing and deserializing. If you use an array instead, you will have no problem with it.

    But it had been easier to answer if you show your code for Multiplayer and Player.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to deserialize a JSON object (using GSON, because I already use it
I'm trying to parse some JSON using the JSon.Net library. The documentation seems a
I want to parse JSON arrays and using gson. Firstly, I can log JSON
In short, this is a sketch of the JSON object I want to parse
I want to parse a JSON object and create a JSONEvent with the given
I am trying to parse a json string straight into a managed object. The
I want to receive a JSON object using Ruby. I've written this: require 'sinatra'
I want to create a data structure that will be parse as a JSON
I am trying to parse the JSON incrementally, i.e. based on a condition. Below
I have an XML file which I want to convert into JSON file using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.