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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:37:06+00:00 2026-06-04T21:37:06+00:00

The following is a snippet from a project based on Spring web MVC 3.1.1.

  • 0

The following is a snippet from a project based on Spring web MVC 3.1.1. Json serialization is made via Jackson.

I have a controller which is mapped to a URL and everything is working fine.

@Controller
@RequestMapping("/vod")
public class VODController {
 private Configuration configuration;
 private SearchAPI     searchAPI;

 @RequestMapping(method = RequestMethod.GET, params = "cmd=list")
 public @ResponseBody GetAssetsReply listVODAssets(long offset, int limit) {
    SearchVODAssetRequest searchVODAssetRequest = new SearchVODAssetRequest();
    //.... some irrelevant code
    return searchAPI.searchVODAssets(searchVODAssetRequest);
 }
}

And this is GetAssetsReply:

public class GetAssetsReply  {
    private long totalAssets;
    private List<VODAsset> assets = new LinkedList<VODAsset>();

    // Getters and setters removed for simplicity
}

VODAsset is an interface:

public interface VODAsset {
    public String getName();
}

And this is its implementation:

public class AssetElement implements VODAsset {
    private String     id;
    private String     name;
    private double     duration;

    // Getters and setters removed for simplicity
}

Finally to the question:
The controller returns me the expected result with one down side – It returns the VOD assets with its ID and duration in addition to its name. What I would expect is to get only the name due to the fact that the object is pointed by the above VODAsset interface.
How can I get this behavior? Any help would be much appreciated

  • 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-04T21:37:08+00:00Added an answer on June 4, 2026 at 9:37 pm

    If I understand your question correctly and you are using Jackson for convert result to JSON, then you can use org.codehaus.jackson.annotate.JsonIgnore to avoid the field to be polupated into JSON result. (Henry) Furthermore, it is possible to add to the interface @JsonAutoDetect(JsonMethod.NONE) which would cause Jackson not to search automatically for fields to serialize and then add @JsonProperty on the fields that are indeed needed for serialization (virtually implementing a white list scheme for the Jackson field serialization strategy).

    Here is the sample code which solves the above problem:

    @JsonAutoDetect(JsonMethod.NONE) //This tells the json serializer not to search for properties to serialize
    public interface VODAsset {
        @JsonProperty //This tells the json serializer that this is a property that it should serialize
        public String getName();
    }
    

    On the other hand per-field ignore scheme can be implemented the following way:

    Marker annotation that indicates that the annotated method or field is
    to be ignored by introspection-based serialization and deserialization
    functionality. That is, it should not be consider a “getter”, “setter”
    or “creator”.

    @JsonIgnore
    public String getId() {
        return id;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Azure web role (MVC 3 project) wont' start with Twilio controller class I have
Posted in spring forum with no response. I have the following code snippet (from
I have the following snippet from my code: switch ($extention) { case gif: $src
From this site: http://www.toymaker.info/Games/html/vertex_shaders.html We have the following code snippet: // transformations provided by
I'm trying to run the following snippet from a brand new rails project in
I have a window-based project with two UITextField s to take input from the
I have a maven project with the following POM snippet: <modelVersion>4.0.0</modelVersion> <artifactId>Foo-Deploy</artifactId> <name>Foo-Deploy</name> <packaging>pom</packaging>
The following snippet from RuntimeUtil.java from jlibs guarantees GC that garbage collection is done.
The following code snippet is from The Official GNOME 2 Developer's Guide : GMemChunk
From the book Groovy and Grails recipes I'm using the following code snippet: String

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.