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 6851787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:17:26+00:00 2026-05-27T01:17:26+00:00

I have a class hierarchy similar to this one: public static class BaseConfiguration {

  • 0

I have a class hierarchy similar to this one:

public static class BaseConfiguration {
}

public abstract class Base {
  private BaseConfiguration configuration;
  public String id;

  public BaseConfiguration getConfiguration() { ... }
  public void setConfiguration(BaseConfiguration configuration) { ... }
}

public class A extends Base {
   public static class CustomConfigurationA extends BaseConfiguration {
       String filename;
       String encoding;
   }

   CustomConfigurationA getConfiguration() { ... }
}

class B extends Base {
   public static class CustomConfigurationB extends BaseConfiguration {
       /* ... */
   }

   CustomConfigurationB getConfiguration() { ... }
}

And json input like this one (which I cannot change myself)

{
    "id":"File1",
    "configuration":{
         "filename":"...",
         "encoding":"UTF-8"
     }
}

I am parsing the JSON in Java with Jackson like this

ObjectMapper mapper = new ObjectMapper();
value = mapper.readValue(in, nodeType);

I want to deserialize classes A, B and others from JSON using JAVA/Jackson. There are no type information embedded in JSON (and can’t be). I can’t use annotations on the classes (I don’t own them) and I (believe) I can’t use mixins since there are potentially arbitrary numbers of classes like A & B (and mixins are not dynamic). Good thing is that the deserializing code knows which is the correct custom class to use for deserializing (basically there is a known mapping from class to configuration class), but I do not know how make Jackson recognize this information when deserializing the JSON.

In short: I want to be able to resolve the deserialization type of the configuration object depending on the surrounding class type by setting whatever is necessary on ObjectMapper. How can this be achieved?

  • 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-27T01:17:26+00:00Added an answer on May 27, 2026 at 1:17 am

    Apparently the answer was to implement something similar to the sixth solution posted at http://programmerbruce.blogspot.com/2011/05/deserialize-json-with-jackson-into.html, which uses unique JSON element names to identify the target type to deserialize to.

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

Sidebar

Related Questions

We have a class hierarchy similar to this one: public class TestDereference { private
I have a class hierarchy, this one: type TMatrix = class protected //... public
Here's the deal. I have a big class hierarchy and I have this one
My current non-compiling code is similar to this: public abstract class A { }
I have this class hierarchy in code: [Table(A)] public class A : IIdentification {
I have a class hierarchy like this: @Entity @Table (name=call_distribution_policies) @Inheritance (strategy=InheritanceType.JOINED) public class
Let's have the following class hierarchy: public class ParentClass implements SomeInterface { } public
Suppose we have the following class hierarchy: class Base { ... }; class Derived1
Let's say I have the following class hierarchy in C++: class Base; class Derived1
I'm trying to set up an inheritance hierarchy similar to the following: abstract class

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.