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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:11:53+00:00 2026-06-14T16:11:53+00:00

Jersey appears to have a set of predetermined default values for JSON nulls while

  • 0

Jersey appears to have a set of predetermined default values for JSON nulls while unmarshalling via JAXB: String => “”, Integer => 0, … is there anyway to easily control these values either with configuration or annotations?

Using Jersey’s POJO mapping I get what I want, which is to map JSON null to Java null, but for other reasons we really need to use JAXB.

It seems like this should be simple however I’m drawing a blank.

Thanks.

  • 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-14T16:11:54+00:00Added an answer on June 14, 2026 at 4:11 pm

    Note: I’m the EclipseLink JAXB (MOXy) lead and a member of the JAXB (JSR-222) expert group.

    The JAXB (JSR-222) specification does not cover JSON-binding so what you are experiencing is Jersey code interacting with the JAXB reference implementation producing some odd results wrt null handling. EclipseLink MOXy is a JAXB compliant implementation that also offers JSON binding that has more natural null handling.

    @XmlRootElement
    @XmlAccessorType(XmlAccessType.FIELD)
    public class Customer {
    
        private String firstName;
    
        @XmlElement(nillable=true) 
        private String lastName;
    
    }
    

    If this was marshalled to JSON the result would be the following. Null values are not marshalled to JSON unless they are annotated with @XmlElement(nillable=true):

    {
        lastName: null
    }
    

    For More Information

    • http://blog.bdoughan.com/2012/04/binding-to-json-xml-handling-null.html

    Jersey Integration

    • http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html
    • https://github.com/jersey/jersey/tree/master/examples/json-moxy
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using jersey jersey.java.net How do I set JSON as the default serialization instead of
I have a jersey client that is getting JSON from a source that I
I am using Jersey and JAXB to build a simple RESTful webservice I have
I use Jersey with JAXB to convert my response to XML. I have several
I have a Jersey based Rest WS which outputs JSON. I am implementing a
I'm new to Jersey, JAXB, and JSON, and fairly green with XML. I'm playing
When positing large files as an InputStream using the Jersey client, it appears that
Using Jersey, I want to be able to have a GET request, that would
So Jersey's default WADL functionality is great! Except if your developing your API to
I am using Jersey v10 and have written the following code.Is this the right

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.