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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:40:17+00:00 2026-06-08T04:40:17+00:00

What is the equiv way in Jackson json annotation for the following jax-b annotations?

  • 0

What is the equiv way in Jackson json annotation for the following jax-b annotations?

I need to produce json rather than xml and need to know the conventional jackson annotations that is equivalently denoted in jax-b.

  1. rename a field.
  2. use getters instead of fields.

These features are especially crucial if the json/xml element name is a java reserved word
like “new“, “public“, “static“, etc.

So that we have to name the POJO fields as “_new_”, “_public_”, “_static_”, etc, respectively,

but use jax-b annotation to rename them back to “new”, “public”, “static”, etc
in the generated XML (and json) elements.

Renaming a field

@XmlAccessorType(XmlAccessType.FIELD)
public class Person{
    @XmlElement(required = true)
    protected String name;
    @XmlElement(required = true)
    protected String address;
    @XmlElement(name = "contractor")
    protected boolean _restricted_ ;
    @XmlElement(name = "new")
    protected boolean _new_ ;
}

Redirect to using property getter (I think this is how it is done in jax-b)

@XmlAccessorType(XmlAccessType.PROPERTY)
public class Person{
    protected String name;
    protected String address;
    protected boolean _restricted_ ;
    protected boolean _new_ ;

    @XmlElement(required = true)
    protected String getName() {return name;}
    @XmlElement(required = true)
    protected String getAddress() {return address;}
    @XmlElement(name = "contractor")
    protected boolean getRestricted() {return _restricted_;}
    @XmlElement(name = "new")
    protected boolean getNew(){return _new_;}
}
  • 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-08T04:40:20+00:00Added an answer on June 8, 2026 at 4:40 am

    Probably it’s a bit late but anyway..

    you can rename a property just adding

    @JsonProperty("contractor")
    

    And by default Jackson use the getter and setter to serialize and deserialize.

    For more detailed information: http://wiki.fasterxml.com/JacksonFAQ

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

Sidebar

Related Questions

I need to write a program for equivalence classes and get this outputs... (equiv
Whats the best way to make the following HTML text block a hardcoded string
I like to know whats the correct way to create a login/logout mechanizm in
I need a way to get only an element with a certain ID and
I'm looking for JS/JQuery way to do the following 1: Display a series of
I have the following meta tags that supposedly prevents browser caching <meta http-equiv=Pragma content=no-cache
I have a web page that is using the following META tag: <META HTTP-EQUIV=refresh
I am programming Android applications, and the best way here may or may not
Does a servlet knows the encoding of the sent form that specified using http-equiv?
I've been using the following data structure for the representation of propositional logic in

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.