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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:19:08+00:00 2026-06-15T09:19:08+00:00

I am pulling a tree of Categories and Items from a REST service. Categories

  • 0

I am pulling a tree of Categories and Items from a REST service. Categories have a “child” attribute that contains a list of Categories and/or Items. Their types are specified in the field “kind”.

Jackson’s polymorphic type handling is great and all working as expected, except one small hitch: the “kind” field itself is not populated. Is there a simple way to get this data onto the pojos? I hope not to have to write custom deserializers.

Here is the base class for Category and Item. The two subclasses add several scalar fields, and aren’t very interesting.

@JsonIgnoreProperties(ignoreUnknown=true)
@JsonTypeInfo(  
    use = JsonTypeInfo.Id.NAME,  
    include = JsonTypeInfo.As.PROPERTY,  
    property = "kind",
    defaultImpl = EntityBase.Impl.class
    )
@JsonSubTypes({
    @Type(value = Item.class, name = "Item"),  
    @Type(value = Category.class, name = "Category")
    })  
public abstract class EntityBase {
    String title;
    String kind;

    public void setTitle(String title) { this.title = title; }
    public String getTitle() { return title; }

    public void setKind(String kind) { this.kind = kind; }
    public String getKind() { return kind; }

    public static class Impl extends EntityBase {}  
}

I’m doing the deserialization with an ObjectMapper something like this:

ObjectMapper mapper = new ObjectMapper();
Category category = mapper.readValue(inputStream, Category.class);

I think it’s so irrelevant that it doesn’t even deserve a tag, but just in case, this is in an Android app.

  • 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-06-15T09:19:09+00:00Added an answer on June 15, 2026 at 9:19 am

    As usual, I spent a few more minutes searching just before posting this question to make sure I hadn’t missed anything obvious.

    I wouldn’t call it obvious, but I tracked down a resolved jira ticket with the answer. The ticket was linked in comments under a post on http://jackson-users.ning.com/, though I’ve lost the link to the post.

    There is a “visible” attribute on the JsonTypeInfo annotation which does just this.

    @JsonTypeInfo(  
        use = JsonTypeInfo.Id.NAME,  
        include = JsonTypeInfo.As.PROPERTY,  
        property = "kind",
        visible = true,                    // <----- add this
        defaultImpl = EntityBase.Impl.class
        )
    public abstract class EntityBase {
        ...
    }
    

    Turns out, this is documented in the javadocs. I had missed it thanks to the excellent SEO on the old 1.5 docs (and the confusing dichotomy between jackson.codehaus.org and fasterxml.com doesn’t help), but now I’ve learned my lesson and I’m looking at docs here: http://wiki.fasterxml.com/JacksonJavaDocs.

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

Sidebar

Related Questions

I'm pulling data from my database that is as such (raw): long's streetWe’d tree
I have a query pulling the last six months of data from a table
I have been have issues trying to retrieve the values from a treeMap that
I have a query pulling data from three tables using LEFT OUTER JOIN for
Pulling my hair out over this one. I have one wordpress install at /2009
im pulling in images from the net, and want to manipulate them a bit
I'm pulling information from the WordPress database. It's definitely pulling all the correct information
I have a two column css layout. Left container holds the dynatree. It's pulling
I have a git repository that I am using and I've screwed up. I
Pulling my hair out with this simple CSS layout. I have a 2-column fixed

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.