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

  • SEARCH
  • Home
  • 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 7416223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:27:06+00:00 2026-05-29T07:27:06+00:00

Is there a JSON library for Java that can handle something like the following

  • 0

Is there a JSON library for Java that can handle something like the following scenario:

public class BaseShapeSender<T extends Shape> {
{
  Collection<T> shapes;

  public void send
  {
    // Sending the shapes collection with JSON
  }
}

public class CircleSender extends BaseShapeSender<Circle>
{

}

Currently I’m using Jersey, but calling circleSender.send() with the above above scenario gives an exception

A message body writer for Java type, class java.util.ArrayList, and MIME media type, application/json, was not found

even when using GenericEntity to send the collection (apparently Jersey can handle Collection<Circle> but the second level of generics is too much). So, I found myself duplicating the sending code in every subclass:

public class CircleSender extends BaseShapeSender<Circle>
{
  Collection<Circle> circles;

  public void send
  {
    // Sending the circles collection with JSON
  }
}

I would love to avoid that if possible since the sending logic is basically the same in all subclasses.

  • 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-29T07:27:07+00:00Added an answer on May 29, 2026 at 7:27 am

    According to this answer Jackson supports both generics as well as polymorphism. GSON (which I’ve stuck with so far) does not until issue 231 is resolved.

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

Sidebar

Related Questions

I need a library to handle JSON objects in Ruby. There are two gems
I'm looking to do something like the following in Java and was wondering whether
Is there a json library for c# that will work with windows phone 7
I'm looking for a Java library that can do Named entity recognition (NER) with
Is there a general-purpose PHP JSON library that detects the level of JSON support
Is there any json library for android which can manage circular reference ? I
I imported this morning following JAVA-Libary to my Android-Project: JSON-Libary I imported it over
We have a library of Java code that we intend to use across projects.
I'm using Google's GSON Library to convert JSON data to Java objects. The issue
I'm trying to find a way to write a java application that can communicate

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.