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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:13:05+00:00 2026-06-08T02:13:05+00:00

I currently use JAXB for a project i’m working on and looking to convert

  • 0

I currently use JAXB for a project i’m working on and looking to convert my libraries archived xml to archived json, To act in my project. I figured I would use Jettison as it seems it would be easier to implement since it actually works with JAXB; however, looking at Older benchmarks in which Jettison was not included I have found Kryo produces smaller files and Serialized and DeSerialized quicker than some alternatives.

Can anyone inform me of the key difference or otherwise how Jettison stacks up to Kryo, especially for future projects such as android applications.

EDIT:

I guess i’m looking for what produces smaller files and operates faster. Human readability can be sacrificed since I don’t plan on reading the files only processing them

  • 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-08T02:13:06+00:00Added an answer on June 8, 2026 at 2:13 am

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

    Since you already have established JAXB mappings and are converting XML to JSON, you may be interested in EclipseLink JAXB (MOXy) which offers both object-to-XML and object-to-JSON mapping using the same JAXB metadata.

    Customer

    Below is a sample model with JAXB annotations.

    package forum11599191;
    
    import java.util.List;
    import javax.xml.bind.annotation.*;
    
    @XmlRootElement
    @XmlAccessorType(XmlAccessType.FIELD)
    public class Customer {
    
        @XmlAttribute
        private int id;
    
        private String firstName;
    
        @XmlElement(nillable=true)
        private String lastName;
    
        private List<String> email;
    
    }
    

    jaxb.properties

    To use 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 (see: http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as-your.html).

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

    input.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <customer id="123" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <firstName>Jane</firstName>
        <lastName xsi:nil="true"/>
        <email>jdoe@example.com</email>
    </customer>
    

    Demo

    The following demo code will populate the objects from XML and then output JSON. Note how there are no compile time dependencies on MOXy.

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

    JSON Ouput

    Below is the output from running the demo code.

    {
       "customer" : {
          "id" : 123,
          "firstName" : "Jane",
          "lastName" : null,
          "email" : [ "jdoe@example.com" ]
       }
    }
    

    A few things to note about the output:

    1. Since the id field is a numeric type it was marshalled to JSON without quotes.
    2. Even though the id field was mapped with @XmlAttribute there are no special indication of this in the JSON message.
    3. The email property had a List of size one, this is properly represented in the JSON output.
    4. The xsi:nil mechanism was used to specify that the lastName field had a null value, this has been translated to the proper null representation in the JSON output.

    For More Information

    • http://blog.bdoughan.com/2011/08/json-binding-with-eclipselink-moxy.html
    • http://blog.bdoughan.com/2012/04/binding-to-json-xml-handling-null.html
    • http://blog.bdoughan.com/2011/04/jaxb-and-json-via-jettison.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need: take in XML and save data to database. Currently using: JAXB to convert
Currently I am working on a project with Spring web-service, hibernate and JAXb. 1)
I currently use the rectangle shape xml tag to specify borders for my views
Is it possible to use JAXB to unmarshall xml to a specific Java class
So in my current project I use the JAXB RI with the default Java
Currently I'm working on converting object to XML, I notice all object properties are
I have a service that needs to generate xml. Currently I am using jaxb
I am currently trying to use the XMLUnit library to compare two XML files.
I'm trying to use JAXB to pull some elements from a large XML file
I'm working on a couple of web services that use JAXB bindings for the

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.