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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:35:03+00:00 2026-06-06T19:35:03+00:00

I’m using jax-rs and adding entity for being marshalled in Jetty by JAXRSOutInterceptor, but

  • 0

I’m using jax-rs and adding entity for being marshalled in Jetty by JAXRSOutInterceptor,
but JSON output is being modified with additional empty property which looks like this:
“$”: “”

The JSONProvider is created and configured as here:

JSONProvider jsonProvider = new JSONProvider();
jsonProvider.setConvertTypesToStrings(true);
jsonProvider.setIgnoreNamespaces(true);
jsonProvider.setIgnoreMixedContent(true);
jsonProvider.setUnmarshallAsJaxbElement(true);
providers.add(jsonProvider);

It is also being marshalled to XML which uses namespaces but I don’t want them in JSON output and input.

The object that is being marshalled is similar to this:

@XmlRootElement(name="myObject1")
@XmlAccessorType(XmlAccessType.FIELD)
@SuppressWarnings("serial")
public class MyObject1 implements Serializable {

    MyObject2 a;
    MyObject2 b;
    MyObject2 c;

// includes getters, setters, hashCode, equals, toString,   
}

When MyObject2 is:

@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@SuppressWarnings("serial")
public class MyObject2 implements Serializable {

    String x;
    String y;
    List<String> z;

// includes getters, setters, hashCode, equals, toString,   
}

The rest output is as following:

{
   "myObject1": {
      "a": {
         "x": "value1",
         "y": "value2",
         "z": "value3",
         "$": ""
      },
      "$": ""
   }
}

How do I get rid of the ending “$”: “”
I read that the Jettison (which is the default JSONProvider implementation that I am using) is by default will represent properties mapped with @XmlValue as ‘$’s but there’s no property ?

Is that caused by implementing Serializable?

  • 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-06T19:35:04+00:00Added an answer on June 6, 2026 at 7:35 pm

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

    Jettison isn’t really a JSON provider but an API that can allow XML libraries to produce/consume JSON. It does a decent job, but there are problems that can occur like the one you are experiencing now. You are also seeing the issues where lists of size one are not marshalled as JSON arrays.

    • http://blog.bdoughan.com/2011/04/jaxb-and-json-via-jettison.html

    If you can’t find a way to make this work with your current set up. Below is what you could do with MOXy as your JSON provider:

    MyObject1

    package forum11262807;
    
    import java.io.Serializable;
    import javax.xml.bind.annotation.*;
    
    @XmlRootElement(name="myObject1")
    @XmlAccessorType(XmlAccessType.FIELD)
    @SuppressWarnings("serial")
    public class MyObject1 implements Serializable {
    
        MyObject2 a;
        MyObject2 b;
        MyObject2 c;
    
    }
    

    MyObject2

    package forum11262807;
    
    import java.io.Serializable;
    import java.util.List;
    import javax.xml.bind.annotation.*;
    
    @XmlAccessorType(XmlAccessType.FIELD)
    @SuppressWarnings("serial")
    public class MyObject2 implements Serializable {
    
        String x;
        String y;
        List<String> z;
    
    }
    

    jaxb.properties

    To specify MOXy as your JAXB provider you need to include a file called jaxb.properties in the same package as your domain model with the following entry:

    javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory
    

    Demo

    Below is some standalone code to demonstrate the reading/writing of the JSON.

    package forum11262807;
    
    import java.io.File;
    import javax.xml.bind.*;
    
    public class Demo {
    
        public static void main(String[] args) throws Exception {
            JAXBContext jc = JAXBContext.newInstance(MyObject1.class);
    
            Unmarshaller unmarshaller = jc.createUnmarshaller();
            unmarshaller.setProperty("eclipselink.media-type", "application/json");
            File json = new File("src/forum11262807/input.json");
            MyObject1 myObject1 = (MyObject1) unmarshaller.unmarshal(json);
    
            Marshaller marshaller = jc.createMarshaller();
            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
            marshaller.setProperty("eclipselink.media-type", "application/json");
            marshaller.marshal(myObject1, System.out);
        }
    
    }
    

    input.json/Output

    The resulting JSON message contains no "$" properties and the list of size 1 is property represented as a JSON array.

    {
       "myObject1" : {
          "a" : {
             "x" : "value1",
             "y" : "value2",
             "z" : [ "value3" ]
          }
       }
    }
    

    JAX-RS Integration

    MOXy includes the MOXyJsonProvider class that makes it easy to configure in your JAX-RS application:

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.