Mined Opinions For API: javax.xml

This tab contains all the opinions collected from Stack Overflow about the API. The other tabs present summaries of the opinions using different algorithms.
  • I found a blog article from the person you mentionned and it works.. details
  • I created a new question for this that I'd like you to answer here: URL_http://stackoverflow.com/questions/18646747/how-to-produce-json-output-with - jersey-1-17-1-using-jaxb This can help others.. details
  • You simple need add @Produces("application/xml") or headers section with content similar to this: headers {Const.HEADER_CONTENT_TYPE_APPLICATION_JSON} to your @RequestMapping.. details
  • I found a blog article from the person you mentionned and it works.. details
  • Thank you.. details
  • Thank u so much.. details
  • Thanks.. details
  • @Jaroslaw.zawila I hoped in Jackson there is an annotation like XmlJavaTypeAdapter in jaxb.. details
  • Great.. details
  • Thanks for the full example, its awesome!!. details
  • Thanks a a lot for your help.. details
  • Thanks!. details
  • Thanks.. details
  • JAXB is a standard that lets you translate between XML and objects.. details
  • Note too that you need not use JAXB -- JAXB is for producing XML (altough there are impls that do some form of JSON output as well).. details
  • @chrylis, it's far from trivial to constuct an elaborate java structure which can serialize to both pretty json and pretty xml.. details
  • I am unable to download the jar file for import org.eclipse.persistence.jaxb.JAXBContextProperties and import org.eclipse.persistence.jaxb.MarshallerProperties which jar i have to use it will be helpfull if i know the link from where can i get it.. details
  • Does JAXB support to receive values (using POST) and saving them to the database but do not returning (using GET) those values?. details
  • Normally mapping of JSON to POJOs works with JAXB without creating an own messageBodyReader, because the message reader for JSON already exists.. details
  • But I feel it like this jaxb thing is not straight forward and it could have been a little easier than the current thing.. details
  • yes I see that before sending the request an OPTIONS call is send It's normal now I decided to make it as simple with text/xml and mapped it to objects with jaxb .thanks anyway.. details
  • I've been able to get it working with JAXB, but I'm specifically looking for Jersey POJO writing, not JAXB writing.. details
  • Thanks for the answer, in this third solution, the example code which is used isColumnPositionMappingStrategy strat new ColumnPositionMappingStrategy();strat.setType(YourOrderBean.class);String[] columns new String[] {"name", "orderNumber", "id"}; // the fields to bind do in your JavaBeanstrat.setColumnMapping(columns);CsvToBean csv new CsvToBean();List list csv.parse(strat, yourReader);what exactly is yourReader here, and how do I input values to bind with bean?. details
  • Works fine, but I have to do it in this way inside the resource method: JAXBContext context JAXBContextFactory.createContext(new Class[] {ONIXMessage.class}, null); How can I fetch the eclipselink JAXBContext from Jersey?. details
  • I pretty much look for anything you've written when dealing with MOXy or JAXB.. details
  • :-) JAXB is cool, but I think I'd do discription.substring(1, discription.length()-1) before converting JSON into XML just for the output.. details
  • What does your JAXB-annotated model look like?. details
  • Since it converts StAX events to/from JSON it can be used with an XML binding tool (JAXB is the standard) to produce JSON from objects.. details
  • You basically need to add a provider for JSON support, like f.e.. details
  • In the past I remember working with XML files, using the JAXB compiler to automatically generate Java classes, and those tags where automatically generated, so I guess some tools to generate code do this, while others do not.. details
  • So, can I do something like: @GET @Path("/userinfo/{id}") @Produces({"application/xml", "application/json"}) public String getUserInfo(@PathParam("id") String id) {String users null;User user null;user new UserManager().getUserInfo(id); JAXBContext jaxbContext JAXBContext.newInstance(User.class);Marshaller jaxbMarshaller jaxbContext.createMarshaller(); jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);jaxbMarshaller.marshal(user, System.out); users jaxbMarshaller.toString(); return users;} .. details
  • Thanks a a lot for your help.. details
  • I created a new question for this that I'd like you to answer here: URL_http://stackoverflow.com/questions/18646747/how-to-produce-json-output-with - jersey-1-17-1-using-jaxb This can help others.. details
  • Yeah, sometimes it's the answers lower-down on the list that actually end-up working.. details
  • If this is what your environment is doing the using JAXBElement is the correct thing to do.. details
  • I think I will modify the question a bit so that it is easy to understand.. details
  • @Molly Usually you can do whatever you want with the values you receive and return anything you want, no matter if it's GET or POST.. details
  • The simplest way of doing this is to use JAXB to create the tooled version of the structure (with something like Jackson as the serialization engine) and then to create a factory method somewhere that will make the structure for you without you having to specify anything extra yourself.. details
  • Take a look at the URL_https://jcp.org/aboutJava/communityprocess/final/jsr339/index.html [JAX- RS-spec] or Jersey User Guide especially section devoted to URL_https://jersey.java.net/documentation/latest/media.html#json [JSON] ( URL_https://jersey.java.net/documentation/latest/media.html#d0e6192 [JAXB- based-JSON-support] ).. details
  • Searching SO and Google for this has not been helpful, and thought I'd bring this to the geniuses at SO for some help.. details
  • Any help would be most appreciated, (de)serialization with JSON and XML with json.org, Jackson, and JAXB has turned into a black and bottomless pit that has consumed almost a month of my life.. details
  • @RSyed - I also have an example on GitHub that you may find helpful: URL_https://github.com/bdoughan/blog20110819 .. details
  • Thanks a lot,that really helps.. details
  • Thanks a lot,that really helps.. details
  • If you used JAXB to generate your classes, you can certainly have something like @XmlElements with different types to parse a List.. details
  • I should clarify, as Perception says, JAXB was originally about mapping between Java and XML, pragmatically may implementations of JAXB also support mapping to to JSON: for example URL_http://wiki.fasterxml.com/JacksonJAXBAnnotations .. details
  • Thanks.. details
  • That's interesting because it seems to indicate that the only part JAXB plays in this is to lend its annotations and some other interfaces (e.g.. details
  • I tried it and the XML consisted of one empty tag only, meaning there's something about the POJO model that JAXB doesn't like.. details
  • If you want to , you can create a separate method just like this very simple (if you already have the JAXB libs) the main class CODESNIPPET_JAVA1 .. details
  • Will result in: { "book" : { "title" : "hello" } } Both org.eclipse.persistence.moxy-2.5.1.jar and org.eclipse.persistence.core-2.5.1.jar are needed on the classpath.While playing around with this myself, I ran into: URL_http://stackoverflow.com/tags/jaxb/hot [hottest-JAXB-answers] .. details
  • JSON binding with JAXB and Jackson in standalone JavaSE app.. details
  • I would like to use JAXB in a JavaSE standalone application to read and write Json files.I managed to do it for XML files with my snippet below, but I don't understand how to switch to Json: CODESNIPPET_JAVA1 .. details
  • can you please give an example.. details
  • I'm using JAXB and MOXy to unmarshal structure like CODESNIPPET_JAVA1 .. details
  • and it works.. details
  • Because of the XML (as I want the same behaviour for XML as well) there is necessity to use @XmlEnumValue etc.. details
  • EDIT: I now found this setting: USE_GETTERS_AS_SETTERS (default: true) Controls whether "getters" that return Collection or Map types can be used for "setting" values (same as how JAXB API works with XML), so that separate "setter" method is not needed.. details
  • Dependencies Remove both CODETERM1 (this module doesn't exist any more in Jersey 2.x) and CODETERM2 (which is only for Jersey 1.x) and add one of the modules CODETERM3 (JAXB) or CODETERM4 (POJO).. details
  • With the reference JAXB implementation this works fine in both XML and JSON (we were using Jackson for the JSON logic).. details
  • Thanks.. details
  • Then use Jackson, which has JAXB support, by adding all the libraries to your project and adding this configuration: CODESNIPPET_JAVA2 .. details
  • Both status() and echo() are working properly.. details
  • Thanks!. details
  • Please note that on processRequest() I'm currently producing a text response, but that will be changed later to produce a JSON.. details
  • Thank You so much for your reply.. details
  • Thank You so much for your reply.. details
  • Thank U so much for your response.. details
  • can you please tell me , on what area i can find the overhead between two test.. details
  • But actually , I have used this tool first time and I am not able to find the difference, accurately.. details
  • Thanks.. details
  • I tried to use Jackson with JAXB module to convert JAXB-object into JSON, which works pretty fine with storing the data.. details
  • JAX-RS and CODETERM6 MOXy includes an implementation of CODETERM7 / CODETERM8 which makes it easy to configure MOXy as your JSON-binding provider.. details
  • You can change this by setting a configured instance on a JAX-RS CODETERM10 class like the one below.. details
  • I have a POJO with JAXB annotations, it works well marshalling to xml and json, however, the xml and json are not compatible since the root tag is lost in json.. details
  • I discovered that when I remove the JAXBElement type from the WS, that it works.. details
  • Thanks!. details
  • I was struggling with this as well, but this question is similar and the answer works URL_http://stackoverflow.com/questions/3422545/binding-a-generic- java-class-to-a-json-using-jaxb [Binding-a-Generic-Java-Class-to-a-JSON-using- JAXB] It's a fairly simple answer although I'd struggle to explain why or how it works and doesn't cause the mapping to occur.. details
  • I was struggling with this as well, but this question is similar and the answer works URL_http://stackoverflow.com/questions/3422545/binding-a-generic- java-class-to-a-json-using-jaxb [Binding-a-Generic-Java-Class-to-a-JSON-using- JAXB] It's a fairly simple answer although I'd struggle to explain why or how it works and doesn't cause the mapping to occur.. details
  • My response object is simple and uses normal annotations: CODESNIPPET_JAVA4 .. details
  • Given a model object CODETERM11 create a CODETERM12 and CODETERM13 2) Write a custom message converter I tried this and it turned out to be a bit complicated since the view must know how to resolve e.g., a CODETERM14 to a CODETERM15 to be able to serialize it into a readable format.. details
  • Based on some arbitration parameter let the controller inject the correct serializer CODESNIPPET_JAVA3 .. details
  • I have to be honest though, I really don't like the idea of having to manage an XML file in addition to my POJO to apply the "views".. details
  • thanks for the information!. details
  • Also, since content has an @XmlValue annotation in the oxm.xml for the JSON binding it can be changed to be handled instead as a regular element (and name it value or whatever you want to call it).. details
  • I hope it help you.. details
  • Update: JAXB annotation are great for interop with XML system, but you should really use Jackson's own annotation if you can.. details
  • You are using JAXB annotations so you need to properly configure your CODETERM1 with the correct module; you need the URL_https://github.com/FasterXML/jackson-module-jaxb-annotations [jackson- module-jaxb-annotations] project.. details
  • It is possible that Jackson will behave similar to Jettison with respect to the JAXB annotations I simply didn't have the time to try it.. details
  • Adding jackson-xc-1.9.2.jar solve this warrning below java.lang.NoClassDefFoundError: org/codehaus/jackson/xc/JaxbAnnotationIntrospector I hope this helps somebody.. details
  • Demo Code** Below is a standalone example you can run to prove that everything works: CODESNIPPET_JAVA3 .. details
  • If the value is coming as 1234AS in this case returns with double quote.How to fix this and making sure its always has double quotes.. details
  • If the value is coming as 1234AS in this case returns with double quote.How to fix this and making sure its always has double quotes.. details
  • Please help .. details
  • Is their a good way to export a mixed HashMap list?. details
  • When the CODETERM8 is equal to CODETERM9 the CODETERM10 value is not marshalled.. details
  • I have opened the following enhancement request to make this use case even easier to handle: URL_http://bugs.eclipse.org/406375 [ URL_http://bugs.eclipse.org/406375 ] .. details
  • I have opened the following enhancement request to make this use case even easier to handle: URL_http://bugs.eclipse.org/406375 [ URL_http://bugs.eclipse.org/406375 ] .. details
  • It addresses JAXBAnnotationIntrospector and JacksonAnnotationIntrospector as well.... details
  • ex: if status != "deleted" -> bind all fields CODESNIPPET_JAVA2 .. details
  • i have a class like : CODESNIPPET_JAVA1 .. details
  • ?thanks .. details
  • I've fixed the factory method for others to see, I hope you don't mind.. details
  • I've fixed the factory method for others to see, I hope you don't mind.. details
  • Your implementation is decent enough.. details
  • I still wonder if there is an even simpler way!.. details
  • Foo You can take advantage of MOXy's path based mapping for this use case.. details
  • Thanks, I updated to the code with my Customer class.. details
  • thanks your suggestion of changing it to Boolean worked.. details
  • But, how do I now ensure that the JSON response returns the value as a JavaScript boolean type, instead of a string (i.e.. details
  • There's a JAXB plugin for adding annotations: URL_http://confluence.highsource.org/display/J2B/Annotate+Plugin [ URL_http://confluence.highsource.org/display/J2B/Annotate+Plugin ] You can hook it into the CODETERM1 phase of a Maven build like so: CODESNIPPET_JAVA1 .. details
  • I tried to get some inputs from the question I posted URL_http://stackoverflow.com/questions/15563351/how-to-dynamically-generate- and-retrieve-json-in-java-code [here] But could not really get any solution.. details
  • I tried to get some inputs from the question I posted URL_http://stackoverflow.com/questions/15563351/how-to-dynamically-generate- and-retrieve-json-in-java-code [here] But could not really get any solution.. details
  • My jaxb annotated class looks like this: CODESNIPPET_JAVA2 .. details
  • Please read URL_http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html [this-blog] , at the bottom you will find how it's done without CODETERM2 .Also go through the answers in the post URL_http://stackoverflow.com/questions/819720/no-xmlrootelement-generated-by- jaxb [No-@XmlRootElement-generated-by-JAXB] .. details
  • I've created a JAXB bean with a few simple fields along with a nested array of other jaxb beans.. details
  • Also note the collection of size one was correctly represented as a JSON array (a problem with some other approaches).. details
  • Also note the collection of size one was correctly represented as a JSON array (a problem with some other approaches).. details
  • The EclipseLink MOXy** implementation of JAXB offers native JSON binding meaning that items like collections of size 1 will be properly converted to JSON.. details
  • Thanks that works.. details
  • Ah should have seen this I was looking at my initialcontext method rather than my marshaller initialization, disabled Marshaller.JAXB_FORMATTED_OUTPUT and it now works.. details
  • Thankyou that works (actually the attribute is ended though there can be an end attribut eas well that I didn't show), thanks again for all your help on this.. details
  • Fantastic, got it working as per suggestion.. details
  • Since MOXy implements that JAXB (JSR-222) specification you can be confident using it for your XML as well.. details
  • Jersey is a great JAX-RS framework, EclipseLink provides JAXB & JPA implementations and is not a Jersey replacement.. details
  • Thanks, btw I saw your blog before (nice one), when I've tried to search a solution to my issue, I just didn't want to change the json provider right now since I'm at the end of the project sprint.. details
  • You can use one or two tools for this: one common combination is to use Jackson for JSON, and JAXB for XML, to use their respective strengths.. details
  • This is how the JAXB works.. details
  • Please clarify your question.. details
  • Thank you!. details
  • Note how the CODETERM1 attribute is used on the CODETERM2 element to indicate a CODETERM3 value.. details
  • JSON OUTPUT** Note how the CODETERM7 value for the CODETERM8 key is represented as proper JSON.. details
  • Also note how the CODETERM9 key doesn't contain any special indicator corresponding to it being an XML attribute in the XML representation.. details
  • I'm trying to write a code which can take either xml or JSON input and out JSON or XML respectively.. details
  • The point being: JAXB does not have any concept of JSON, so any support for JSON relies on retrofitting JSON to an XML model of the world (StaX).. details
  • The net effect is that rather than writing lots of little getJSONObject() calls, you invest in setting up corresponding classes, this should result in nicely structured code, where the processing of the data, that is the real business logic, is separated from the parsing code, which I view as "plumbing".. details
  • Hope it helps.. details
  • EclipseLink JAXB (MOXy) offers native JSON-binding (I'm the MOXy lead) with it you could do something like: CODESNIPPET_JAVA6 .. details
  • I tried it and the XML consisted of one empty tag only, meaning there's something about the POJO model that JAXB doesn't like.. details
  • That's interesting because it seems to indicate that the only part JAXB plays in this is to lend its annotations and some other interfaces (e.g.. details
  • This would be useful as I do not believe what you are seeing is a JAXB issue, but an issue in the JSON binding layer that you are using.. details
  • The URL_http://jcp.org/en/jsr/detail?id=222 [JAXB-(JSR-222)] specification does not cover JSON-binding so this type of support is beyond the spec.. details
  • Make a JAXB context resolver like this CODESNIPPET_JAVA1 .. details
  • Added the context resolver to your client CODESNIPPET_JAVA2 .. details
  • Update: I confirmed that CODETERM9 marshalling is indeed working for scalar CODETERM10 properties by adding a scalar CODETERM11 property and observing the expected output in the JSON.. details
  • The problem is that it's only working for the CODETERM4 property and not the CODETERM5 property.. details
  • You may be interested in the JSON support we've added to EclipseLink JAXB (MOXy).. details
  • @theSshow - I was suggestion if you couldn't make the boolean property Boolean (to support a null value), then you could create an AdaptedEmployee class (it should not extend Employee to use with the XmlAdapter (see URL_http://blog.bdoughan.com/2010/12/jaxb-and-immutable - objects.html).. details
  • Blaise, thanks for your answer!. details
  • It's almost perfect.. details
  • Jeff, thanks for the response.. details
  • I'm just putting forward my solution (using JAXB), as I have used it to solve issues like his when I was using the Jackson lib.... details
  • No, but I'll look into it, thanks!.. details
  • No, but I'll look into it, thanks!.. details
  • True, the parts of the Javadoc that I omitted above include "This is identical to how JAXB handles type information annotations; and is chosen since it is the dominant use case.. details
  • We make the value of these keys JSON arrays since keys are not allowed to repeat.. details
  • To get this JSON representation you have mapped your model with the CODETERM1 annotation which tells JAXB to use the value of the CODETERM2 annotation as the inheritance indicator.. details
  • Anyway, thanks for the help.. details
  • Appendix D.3 of JAXB 2.1 specs says that the conversion to uppercase _must_ be done, hence you probably should hope that json marshaling offers something.. details
  • Jackson supports a subset of JAXB metadata and does not currently support the CODETERM1 class.. details
  • EclipseLink JAXB (MOXy) offers support for all JAXB constructs in our JSON- binding implementation and it may be a better fit for you use case: URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html [ URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html ] Below is a link to some official Jersey examples that leverage MOXy as the JSON provider: URL_https://github.com/jersey/jersey/blob/master/examples/json-moxy/README.html [ URL_https://github.com/jersey/jersey/blob/master/examples/json-moxy/README.html ] .. details
  • EclipseLink JAXB (MOXy) offers support for all JAXB constructs in our JSON- binding implementation and it may be a better fit for you use case: URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html [ URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html ] Below is a link to some official Jersey examples that leverage MOXy as the JSON provider: URL_https://github.com/jersey/jersey/blob/master/examples/json-moxy/README.html [ URL_https://github.com/jersey/jersey/blob/master/examples/json-moxy/README.html ] .. details
  • Your JAXB bean is a perfectly reasonable representation of your JSON data.. details
  • The URL_http://jcp.org/en/jsr/detail?id=222 [JAXB-(JSR-222)] spec does not cover JSON binding so the answer ultimately comes down to how/if your JAX-RS implementation interprets JAXB metadata to produce/consume JSON.. details
  • Thanks in advance!. details
  • My web application works fine (I'm able to successfully access other resources) but this one resource (that I pass my JSON to) returns a 415 Media Type Unsupported exception.. details
  • If you don't use JAXB annotated objects, but simple POJO's, you can get the correct behaviour by simply enabling the POJO mapping feature, together with the Jackson JSON library.. details
  • and then your method would look like this: CODESNIPPET_JAVA2 .. details
  • To pass your specialized JSONJAXBContext to Jersey, you will finally need to implement a JAXBContext ContextResolver: CODESNIPPET_JAVA1 .. details
  • This code works fine if I transfer a class ( MyClass ) that has @XmlRoolElement Client CODESNIPPET_JAVA1 .. details
  • But if I try to transfer a primitive, like String, Integer, Boolean, etc... Client CODESNIPPET_JAVA2 .. details
  • Looks like getJAXBContext() in MOXyJSONProvider might not be picking up a context correctly (and thus creating a JAXB context that doesn't know what "eclipselink.media-type" is).. details
  • Actually no because the json response is not an array of objects but an object which contains an key "dossiers" and a array as the value.. details
  • Actually no because the json response is not an array of objects but an object which contains an key "dossiers" and a array as the value.. details
  • Send Us Your Feedback** We like to get feedback on changes we make, especially on streams that are still in development.. details
  • We're working on improving our Maven setup.. details
  • Then you will need to override the CODETERM1 in the external mapping file as well.. details
  • Send Us Your Feedback** We like to get feedback on changes we make, especially on streams that are still in development.. details
  • Below is how you an support your use case with your CODETERM1 class as annotated with EclipseLink JAXB (MOXy).. details
  • , but if you change the type of data attribute to String it will look like due to the way Jaxb handles Strings and primitives: CODESNIPPET_JAVA3 .. details
  • @TomAnderson - I have entered an enhancement request to support this use case.. details
  • Below is an example where the same object model is mapped to two different weather services (Google and Yahoo) URL_http://blog.bdoughan.com/2011/09/mapping-objects-to-multiple-xml-schemas.html [ URL_http://blog.bdoughan.com/2011/09/mapping-objects-to-multiple-xml-schemas.html ] MOXy also supports both XML and JSON binding: URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html [ URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html ] MOXy also integrates easily with JAX-RS implementations: URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html [ URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html ] .. details
  • Below is an example where the same object model is mapped to two different weather services (Google and Yahoo) URL_http://blog.bdoughan.com/2011/09/mapping-objects-to-multiple-xml-schemas.html [ URL_http://blog.bdoughan.com/2011/09/mapping-objects-to-multiple-xml-schemas.html ] MOXy also supports both XML and JSON binding: URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html [ URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html ] MOXy also integrates easily with JAX-RS implementations: URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html [ URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html ] .. details
  • Additionally my API needs to support both XML and JSON.. details
  • and the Resource looks like this: CODESNIPPET_JAVA3 .. details
  • Everything is working fine except that the generated responses contain the setters info e.g.. details
  • If you update Jackson to 2.0 it is not deprecated: URL_http://fasterxml.github.com/jackson- databind/javadoc/2.0.0/com/fasterxml/jackson/databind/ObjectMapper.html [ URL_http://fasterxml.github.com/jackson - databind/javadoc/2.0.0/com/fasterxml/jackson/databind/ObjectMapper.html] You can see my configuration here (Spring): URL_http://stackoverflow.com/questions/12514285/registrer- mappingjackson2httpmessageconverter-in-spring-3-1-2-with-jaxb-annotati [Registrer-MappingJackson2HttpMessageConverter-in-Spring-3.1.2-with-JAXB- annotations] .. details
  • The stack trace clearly indicated that a JAXB implementation was being used with the JSON and MOXy supports more JAXB annotations than Jackson does.. details
  • whereas the best I can get it CODESNIPPET_JAVA12 .. details
  • Put some assertions to check not null** objects and list not empty**.. details
  • Put some assertions to check not null** objects and list not empty**.. details
  • Pls Help !!!. details
  • Note how only the standard JAXB APIs are used.. details
  • Things to note about the JSON: The CODETERM5 value is used to represent that the CODETERM6 is null.. details
  • _**Demo**_ MOXy doesn't just interpret JAXB annotations it is a JAXB implementation so the standard JAXB runtime APIs are used.. details
  • For this example I'm just using the standard JAXB (JSR-222) annotations which have are available in the JDK/JRE since Java SE 6.. details
  • In the XML representation CODETERM10 was an attribute, but in the JSON representation there is not need for it to be specially represented.. details
  • EclipseLink JAXB (MOXy)** supports mapping a single object model to both XML and JSON with the same metadata: URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html [ URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html ] License Information** URL_http://wiki.eclipse.org/EclipseLink/FAQ/General#How_is_EclipseLink_Licensed.3F [ URL_http://wiki.eclipse.org/EclipseLink/FAQ/General How_is_EclipseLink_Licensed.3F] DOMAIN MODEL** Below is the domain model we will use for this example.. details
  • The CODETERM8 of type CODETERM9 was correctly marshalled without quotes.. details
  • EclipseLink JAXB (MOXy)** supports mapping a single object model to both XML and JSON with the same metadata: URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html [ URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html ] License Information** URL_http://wiki.eclipse.org/EclipseLink/FAQ/General#How_is_EclipseLink_Licensed.3F [ URL_http://wiki.eclipse.org/EclipseLink/FAQ/General How_is_EclipseLink_Licensed.3F] DOMAIN MODEL** Below is the domain model we will use for this example.. details
  • The collect of phone numbers is of size 1 and is correctly bound by square brackets.. details
  • The collect of phone numbers is of size 1 and is correctly bound by square brackets.. details
  • Please advise the best pattern for serialising JAXB Lists.. details
  • So far I have been creating inner classes to support the wrapper, though I don't like the plumbing as it were as I then need to do it for every pojo.. details
  • There have been many questions as to how why list types are not serialising, however I'm questioning what is a good practice to serve a list type of beans in a simple way.. details
  • I tried making a generic class like CODETERM1 and create new instances on return but JAXB appears to not like this.. details
  • I'm using this in a Spring/MVC RESTful application where I need to support both JSON and XML.. details
  • Don't return Strings in your methods but Customer objects it self and let JAXB take care of the de/serialization.. details
  • 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.. details
  • The CODETERM7 mechanism was used to specify that the CODETERM8 field had a CODETERM9 value, this has been translated to the proper null representation in the JSON output.. details
  • Even though the CODETERM3 field was mapped with CODETERM4 there are no special indication of this in the JSON message.. details
  • EDIT: I guess i'm looking for what produces smaller files and operates faster.. details
  • EDIT: I guess i'm looking for what produces smaller files and operates faster.. details
  • 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.. details
  • I figured I would use URL_http://jettison.codehaus.org/ [Jettison] as it seems it would be URL_http://blog.bdoughan.com/2011/04/jaxb-and-json-via-jettison.html [easier- to-implement] since it actually works with JAXB; however, looking at URL_http://code.google.com/p/thrift-protobuf-compare/wiki/Benchmarking [Older- benchmarks] in which Jettison was not included I have found URL_http://code.google.com/p/kryo/ [Kryo] produces smaller files and Serialized and DeSerialized quicker than some alternatives.. details
  • As you can see the CODETERM8 value appears without quotes: CODESNIPPET_JAVA6 .. details
  • Since answering these questions will necessarily involve more community input than we've had yet since the project is so new, I was thinking we'd wait until a post-1.0 release to add XML support.. details
  • Since answering these questions will necessarily involve more community input than we've had yet since the project is so new, I was thinking we'd wait until a post-1.0 release to add XML support.. details
  • Priorities could obviously change if there's enough momentum in that direction, but I just don't see it happening in the next week.. details
  • In my application the JAXB output generates like: CODETERM1 this is method call to the spring Object XML Mapping Marshallers that generate XML files.. details
  • Now, I also like to generate JSON files after this line.. details
  • Can I create one class, annotate it with JAXB annotations(for XML support) and declare in web.xml for JSON (Jackson library) support?. details
  • Can I create one class, annotate it with JAXB annotations(for XML support) and declare in CODETERM1 CODESNIPPET_JAVA1 .. details
  • Demo Below is a standalone example you can run to prove everything works.. details
  • Note sadly that URL_http://stackoverflow.com/questions/5794713/java-util- map-to-json-object-with-jersey-jaxb-jackson [Java.util.Map-to-JSON-Object- with-Jersey-/-JAXB-/-Jackson] was not helpful, though it showed great promise.. details
  • JAX-RS Integration** MOXy includes the MOXyJsonProvider class that makes it easy to configure in your JAX-RS application: URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html [ URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html ] .. details
  • Demo Below is some standalone code to demonstrate the reading/writing of the JSON.. details
  • JAX-RS Integration** MOXy includes the MOXyJsonProvider class that makes it easy to configure in your JAX-RS application: URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html [ URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html ] .. details
  • any effort put into resolving this issue?. details
  • With JAXB there are two type's of CODETERM1 supported.. details
  • Fundamentally, XML (and by extension JAXB) likes to trace everything back to a single root node/object.. details
  • So to model it, you need something like this: CODESNIPPET_JAVA1 .. details
  • Thanks in advance.. details
  • The object being serialized and de-serialized contains some standard objects that are stored in MySql.. details
  • Note that I'm not saying this solution is optimal, just what has worked for us.. details
  • It seems pretty basic, but I haven't been able to find any examples online (maybe I'm google searching the wrong things).. details
  • So it looks something like this: CODESNIPPET_JAVA4 .. details
  • Therefore, my desired JSON response would look something like this: CODESNIPPET_JAVA5 .. details
  • However, of course, it returns all the Employee attributes in the employees list, like this: CODESNIPPET_JAVA6 .. details
  • Below is what your object model could look like.. details
  • You can add the necessary supporting APIs if you are using Java SE 5.. details
  • You could leverage the JSON-Binding and external mapping document in EclipseLink JAXB (MOXy) to support your use case.. details
  • The above should get you started... Also, you would need to mark each subclass like so: CODESNIPPET_JAVA2 .. details
  • For JAXB I believe you need to annotate your entity like below: CODESNIPPET_JAVA2 .. details
  • As a simple test, I return a bean of Book, and it gets output as JSON, but the JAXB object (delivery schedule) stays in an XML format.. details
  • and the relevant resource signature looks like this: CODESNIPPET_JAVA2 .. details
  • Any help very gratefully received!. details
  • ( URL_https://groups.google.com/d/topic/google-appengine- java/uImBt6fOhww/discussion%20original [original] ) I have put together a simple json REST service using jersey, jaxb and jackson.. details
  • However, all subsequent requests after this work fine, the class then seems to have been loaded.. details
  • The Xml is fine, the json is nearly fine except that because Json directly supports arrays having elements like ipi-list and artist-list doesnt seem very json, is it possible to generate more json like json from my model ?. details
  • Generating more json like json from JAXB and Jersey.. details
  • We have a whole set of JAX-RS REST services running on top of Apache CXF and Jackson.We use JAXB annotations to take care of marshalling POJOs to JSON, works great.. details
  • Also, you do not have to use JAXB annotations, unless you either want to use JAXB, or another package that can also use them: Jackson, for example, supports its own annotations as well as JAXB ones.. details
  • Jersey uses serialization frameworks like JAXB (xml) and Jackson (json, bson, xml, csv) for actual reading/writing of content.. details
  • You can define custom serializer (and deserializer if you need it back) using @JsonSerialize(contentUsing=MySerializer.class); (contentUsing because it's to be used for List values, not List itself).. details
  • For URL_http://www.eclipse.org/eclipselink/moxy.php [EclipseLink-JAXB-(MOXy)] 's JSON binding, the correct mapping would be the following.. details
  • I'm open to trying other ContextResolvers/Serializers, but I haven't been able to find one that works, so code examples would be nice.. details
  • I have a JAXBContextResolver (an implementation of ContextResolver) that looks like this: CODESNIPPET_JAVA4 .. details
  • It will correctly marshal collections of size 1 wrapped as a JSON array.. details
  • EclipseLink JAXB (MOXy) provides native JSON-binding support.. details
  • Both fields had null values.. details
  • You can change this behaviour by setting the CODETERM2 property on CODETERM3 to true.. details
  • EclipseLink JAXB (MOXy) offers native support for JSON.. details
  • This manual could be useful for you: URL_http://jersey.java.net/nonav/documentation/latest /json.html#json.jaxb.approach.section [link] .. details
  • This manual could be useful for you: URL_http://jersey.java.net/nonav/documentation/latest /json.html#json.jaxb.approach.section [link] .. details
  • As an alternative to Jettison, your original JSON input can be easily parsed with URL_https://github.com/beckchr [StAXON] 's CODETERM2 , which works with any JAXB implementation: CODESNIPPET_JAVA4 .. details
  • For more information on StAXON's JAXB support, refer to the URL_https://github.com/beckchr/staxon/wiki/Using-JAXB [Using-JAXB] wiki page.. details
  • For more information on StAXON's JAXB support, refer to the URL_https://github.com/beckchr/staxon/wiki/Using-JAXB [Using-JAXB] wiki page.. details
  • The JAXB-annotated model class is like this: CODESNIPPET_JAVA3 .. details
  • We could eliminate this class if your JSON looked like: CODETERM5 .. details
  • Jettison is an interesting library but there are some issue you will encounter using it: URL_http://blog.bdoughan.com/2011/04/jaxb-and-json-via-jettison.html [ URL_http://blog.bdoughan.com/2011/04/jaxb-and-json-via-jettison.html ] Demo Only the standard Java SE APIs are used.. details
  • If you are ultimately looking for a way to interact with JSON using a JAXB (JSR-222) implementation, then the following is how it can be done using MOXy.. details
  • Jettison is an interesting library but there are some issue you will encounter using it: URL_http://blog.bdoughan.com/2011/04/jaxb-and-json-via-jettison.html [ URL_http://blog.bdoughan.com/2011/04/jaxb-and-json-via-jettison.html ] Demo Only the standard Java SE APIs are used.. details
  • So, you've got two choices: 1. configuring JAXB to be more standard ( URL_http://stackoverflow.com/questions/1145476/how-do-i-marshal-nested-lists-as-json-using-jersey-i-get-an-array-of-nulls-or-a [see-here] for more); 2. using Jackson instead of JAXB which I recommend.. details
  • Thanks to URL_http://stackoverflow.com/questions/2199453/how-can-i-customize- serialization-of-a-list-of-jaxb-objects-to-json/3143214#3143214 [How-can-I -customize-serialization-of-a-list-of-JAXB-objects-to-JSON?]. details
  • Given a class like this: CODESNIPPET_JAVA1 .. details
  • Many also allow you to use standard object binding methodologies such as URL_http://www.oracle.com/technetwork/articles/javase/index-140168.html [JAXB] do define your deserialization mappings using annotations.. details
  • I prefer JAXB and work with Lists which include extra POJOs.. details
  • Looks like you are making use of JAXB for XML and Jackson for JSON.. details
  • I have a class CODETERM2 that has a CODETERM3 field and it's annotated with CODETERM4 When I return any User object from my resources, everything is fine.. details
  • I'm using a JAXB adapter... CODETERM1 that formats my dates in a standard format for the JSON-consuming clients.. details
  • You can also use JPA annotations on the same objects and a JPA provider like Eclipse Link for a lot of your database needs.. details
  • I had a go at creating a schema from the example json I had but didnt get it working for al but the simplest example.. details
  • I had a go at creating a schema from the example json I had but didnt get it working for al but the simplest example.. details
  • Thanks.. details
  • I have a class that has JAXB and bean validation annotations, much like the following: CODESNIPPET_JAVA1 .. details
  • Thanks!. details
  • or alternatively, modify json marshaling so it will use the enum "value" method instead the enum name?. details
  • If you are using JAXB in combination with JAX-RS (Java API for RESTful webservices), this is easy.. details
  • MOXy does look like a very promising candidate in XML space -- giving JAXB RI and XStream run for their money.. details
  • (That works rather well in practice.). details
  • You then need to work out whether the URI refers to something you know (i.e., resolve the URI and see if it points into yourself) and deal with the fragment identifier.. details
  • I would recommend using URL_http://jackson.codehaus.org [Jackson] as it is superior to other recommended alternatives when producing JSON, and for XML either: Use a JAXB implementation with JAXB annotations (Jackson can optionally support JAXB annotations as well, so very little overhead of 2 libs) Use URL_https://github.com/FasterXML/jackson-xml-databind [Jackson-xml-databind] module to produce XML using Jackson itself (in format that is usually identical to JAXB produced) I do NOT think that you absolute must use a single library or framework, and the result is often better if you just choose best choice for each separately.. details
  • Demo The standard JAXB APIs are used to do the conversions to/from JSON and XML: CODESNIPPET_JAVA2 .. details
  • Apache Jersey has decent JAXB support.. details
  • Apache Jersey has decent JAXB support.. details
  • I would recommend you to take a look at the following discussion regarding its internals URL_http://stackoverflow.com/questions/1071749/how-to-reuse-jerseys-json-jaxb- for-serialization [related-post] .. details
  • URL_http://blog.bdoughan.com/2011/08/json-binding-with-eclipselink-moxy.html [ URL_http://blog.bdoughan.com/2011/08/json-binding-with-eclipselink-moxy.html ] In addition to the JAXB annotations MOXy extensions (such as @XmlPath) are supported making it even easier to have one annotated model that can be used for both XML and JSON: URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html?m=0 [ URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html?m=0 ] .. details
  • URL_http://blog.bdoughan.com/2011/08/json-binding-with-eclipselink-moxy.html [ URL_http://blog.bdoughan.com/2011/08/json-binding-with-eclipselink-moxy.html ] In addition to the JAXB annotations MOXy extensions (such as @XmlPath) are supported making it even easier to have one annotated model that can be used for both XML and JSON: URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html?m=0 [ URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html?m=0 ] .. details
  • It seems to have good JAXB support out of the box.. details
  • Can anyone recommend some Java JSON libraries that makes a good reuse of JAXB annotations?Lightweight libraries are preferred.. details
  • Which Java JSON libraries make good reuse of JAXB annotations?. details
  • I am developing a project that already uses XML serialization, so I need an elegant solution to support JSON, by reusing the JAXB annotations.. details
  • You can use Object to Xml converter like JAXB to make your life easier.. details
  • GSON from google : URL_http://code.google.com/p/google-gson/ [ URL_http://code.google.com/p/google-gson/ ] , or Jackson the library used in spring : URL_http://jackson.codehaus.org/ [ URL_http://jackson.codehaus.org/ ] and I would concur with others suggesting jaxb for XML to pojo, well supported lots of tools : its the standard.. details
  • The above example works, so, please, be more precise.. details
  • I've used org.w3c.dom.Element maybe using another one may help navigate through the response (if jaxb supports it).. details
  • Finally, Jackson supports JAXB annotations if you must use them (for example, when using JAXB for producing XML).. details
  • Maybe I wasn't specifying the MediaType in the invocation of the service ;) thanks.. details
  • I had similar problem and I resolved it by creating custom JAXBContextResolver and manually specifying which classes are going to play nicely with json serialization: CODESNIPPET_JAVA1 .. details
  • This involves creating a CODETERM2 like this: CODESNIPPET_JAVA1 .. details
  • Something like CODESNIPPET_JAVA4 .. details
  • JAX-RS supports the use of JAXB (Java API for XML Binding) to bind a JavaBean to XML or JSON and vise versa.. details
  • I cant seem to post JSON to my webservice but XML works fine: CODESNIPPET_JAVA1 .. details
  • Any help would be greatly appreciated.. details
  • Thanks for the link, Blaise.. details
  • Quite honest comparison, regarding your position.. details
  • I don't know very well JaxB, and indeed both libraries are pretty close (with the big advantage of the "standardization" for JaxB).. details
  • I really find SimpleXML a good tool, no jar / classpath problems, easy to use (as is JaxB), pretty fast, good error reporting when somethings goes wrong (XML element not mapped for example), and so on.. details
  • please specify your question more... you might want to have a look at JAXB.. details
  • I insist on unmarshalling to this structure: CODESNIPPET_JAVA1 .. details
  • edit: I asked my question another way to try to make it clear: URL_http://stackoverflow.com/questions/5881058/how-to-map-a-bean-structure- to-a-different-schema-with-jax-rs [how-to-map-a-bean-structure-to-a-different- schema-with-jax-rs] .. details
  • Summary is not present as an attribute in the received json, but as a value of the "fields" attribute.. details
  • I want to receive and emit JSON objects from Java classes like the following: CODESNIPPET_JAVA1 .. details
  • Thanks.. details
  • Thanks, this is the solution - although I would not have understood what to do without many other similar SO Questions/Answers I found :-) I will post the detailed solution in the Question.. details
  • Skaffman, I've tried registering a JAXB annotation introspector following the spec ( URL_http://wiki.fasterxml.com/JacksonJAXBAnnotations ) but I don't see how to dynamically plug that into my restful framework (RESTEasy).. details
  • Skaffman, I've tried registering a JAXB annotation introspector following the spec ( URL_http://wiki.fasterxml.com/JacksonJAXBAnnotations ) but I don't see how to dynamically plug that into my restful framework (RESTEasy).. details
  • @Colin: I just said that Jackson supports JAXB annotations as well.. details
  • Thanks for the response.. details
  • It isn't a generic data modeling framework with flexible bindings.. details
  • POJO to XML** JAXB is the Java standard ( URL_http://jcp.org/en/jsr/detail?id=222 [JSR-222] ) for converting Java objects to/from XML (I am a member of the JAXB expert group): URL_http://bdoughan.blogspot.com/2010/07/jaxb-xml-binding-standard.html [ URL_http://bdoughan.blogspot.com/2010/07/jaxb-xml-binding-standard.html ] POJO to JSON** People have been using JAXB with URL_http://jettison.codehaus.org/ [Jettison] to produce JSON.. details
  • Just make sure your pojos are annotated correctly.. details
  • Here is a simple pojo CODESNIPPET_JAVA1 .. details
  • When I use a list of Strings - everything works perfectly fine!. details
  • My Download class looks pretty much like this (and as I've mentioned already - this works pretty fine when used directly): CODESNIPPET_JAVA5 .. details
  • Given an entity pojo, I can annotate it with Hibernate, JAXB and JSON annotations so that the same class can be written to the database as well as serialize/deserialize for message exchange.. details
  • I think you should be able to just construct ObjectMapper (which does not add JAXB introspector by default), and register it via standard JAX-RS provider mechanism.. details
  • The POJO's which represent my resources are JAXB (XML) annotated simple Java classes (they are generated from a schema definition - so they have the annotations).. details
  • It also URL_http://docs.codehaus.org/display/JACKSON/Jackson+JAXB+Support [supports- JAXB-annotations] just like Jettison.. details
  • If I change it to CODETERM2 the JSON response will treat it as a Sting and keep the double quotes in the response.. details
  • The Java class could look like the one below.. details
  • You got it, but works if I leave XML beans out.. details
  • In fact I find more clean to avoid this JSON to JAXB translation my first solution was using.. details
  • My starting framework is JBoss RESTEasy (JAX-RS implementation) that provides an elegant way to consume Rest services JSON services by mapping JSON to JAXB thru Jettison framework (it works also in the other way if you want to provide REST service and produce JSON from JAXB).. details
  • So I launch a simple request to Twitter : CODESNIPPET_JAVA1 .. details
  • Thanks in advance .. details
  • Rather it is due to whatever processes JAXB annotations, and how it chooses to handle null values of Java objects.. details
  • Rather it is due to whatever processes JAXB annotations, and how it chooses to handle null values of Java objects.. details
  • I'd recommend JAXB + Jackson.. details
  • Thanks!. details
  • your blog is useful!.. details
  • Perhaps its support was not enabled: URL_http://wiki.fasterxml.com/JacksonJAXBAnnotations .. details
  • MappedBuilder builder JSONConfiguration.mapped(); builder.arrays("industries"); builder.rootUnwrapping(true); this.context new JSONJAXBContext(builder.build(), Company.class); } .. details
  • I want something like this: {"id":"0","industries":[{"id":"0","name":"Technologies"}],"name":"Google Inc."} But I get: {"id":"0","industries":{"id":"0","name":"Technologies"},"name":"Google Inc."} Here is my Entity: CODESNIPPET_JAVA1 .. details
  • Now: simple solution for most JAX-RS implementations is to not use JAXB annotation based approach at all, but a JSON-specific serializer, such as URL_http://jackson.codehaus.org/ [Jackson] 's JacksonJsonProvider (Jackson can actually use JAXB annotations, too).. details
  • It will by default include null values for properties, although this is configurable in case you want to suppress nulls.. details
  • (@XmlElement(nillable=true) Which makes the response look like, CODESNIPPET_JAVA3 .. details
  • I want it to be like, CODESNIPPET_JAVA4 .. details
  • The response looks like this CODESNIPPET_JAVA2 .. details
  • I tried setting xml element attribute nillable true.. details
  • To support both JSON and XML messages do the following: CODESNIPPET_JAVA2 .. details
  • Note that we are already using a JAXB ContextResolver to URL_http://blogs.oracle.com/japod/entry/configuring_json_for_restful_web [ensure] the JSON is correct for a single row.. details
  • Since this has to do with Jersey the first thing I would recommend is to avoid JAXB all together since JAXB (in context of XML or JSON) ain't HATEOAS.. details
  • It has support for JAXB annotations so you would be able to work with JSON and beans generated.. details
  • Thanks for that but I would prefer to not use any plugs in, I know there is a simple way that I could do it with a simple for each object in the array loop.I had it going before but I cant find it again.. details
  • All good so far.. details
  • For example, I'd like to be able to call POST /employee/ with a JSON thatlooks like this: CODESNIPPET_JAVA3 .. details
  • But, instead, I have to pass in something like this: CODESNIPPET_JAVA4 .. details
  • There are several ways to parse JSON with it: Streaming (like Sax) Tree (like DOM) Object-mapped (like JAXB) EDIT: Take org.json classes, there are URL_http://developer.android.com/reference/org/json/package-summary.html [already-in] the android API.. details
  • Not straightforward, but I'd combine JAXB, Jackson and BeanUtils.. details
  • I hope it helps you... .. details
  • I hope it helps you... .. details
  • URL_https://jaxb.dev.java.net/guide/Mapping_your_favorite_class.html#HashMap ["JAXB-spec-defines-a-special-handling-for-Map-when-it's-used-as-a-property- of-a-bean."]. details
  • I am successfully marshaling a POJO into JSON using JAX-RS and JAXB annotations.. details
  • You only need something like this in your ressources (supposing DetailProduit is your object you want to serialize and that DetailProduit.java is jaxb tagged and in package.of.your.model) CODESNIPPET_JAVA2 .. details
  • For POJO to XML I suggest using URL_http://www.oracle.com/technetwork/articles/javase/index-140168.html [JAXB] (there are other libraries as well, such as XStream for example, but JAXB is standardized).. details
  • I think I ended up tracing through it and found that it was a problem in the json provider.. details
  • Yeah., But sometimes I may need to marshall objects which has @Entity annotation too., In that case it will conflict if I try to wrap it in JAXBElement.. details
  • What's the problem?. details
  • It was a problem with jaxb.. details
  • Thanks for quick response I am facing javax.xml.bind.JAXBException: property "eclipselink.media-type" is not supported exception.. details
  • The problem was the we left the old JAXB provider hanging around with it's @Provider annotation.. details
  • The problem is that most of what I found is for webapps, in which the part of the configuration which I need is under the hood.. details
  • There also must be a way of doing this using PropertyNamingStrategy, the problem I am facing with it is that Spring MVC is handling it somehow differently than serializing something directly with ObjectMapper from JAXB objects.. details
  • Thanks for quick response I am facing javax.xml.bind.JAXBException: property "eclipselink.media-type" is not supported exception.. details
  • The exception being thrown is an RI exception (com.sun.xml.internal.bind.v2.runtime package) so EclipseLink MOXy is not being picked up as the JAXB provider.. details
  • I think I ended up tracing through it and found that it was a problem in the json provider.. details
  • Have to go, sorry.. details
  • My classes have jaxb annotations and the system application provider seems to interfere with the jackson json provider.. details
  • Here is a complete example of how this can be done with EclipseLink JAXB (MOXy): URL_http://blog.bdoughan.com/2011/08/json-binding-with-eclipselink - moxy.html.. details
  • +1 - Also since JAXB is the default binding layer for JAX-RS you can just return a JAXB model class and the JAX-RS implementation will leverage JAXB to convert it to XML: URL_http://blog.bdoughan.com/2010/08/creating-restful-web - service-part-35.html.. details
  • There is also possibility that JAXB annotation introspector extension (it's a Jackson add-on) could have a bug here.. details
  • The exception being thrown is an RI exception (com.sun.xml.internal.bind.v2.runtime package) so EclipseLink MOXy is not being picked up as the JAXB provider.. details
  • I'm attempting to follow the example located URL_http://stackoverflow.com/questions/14734741/converting-json-to-xml-and- vice-versa-using-jackson-api-and-jaxb-annotation [here] but get an javax.xml.bind.PropertyException.. details
  • I'm attempting to follow the example located URL_http://stackoverflow.com/questions/14734741/converting-json-to-xml-and- vice-versa-using-jackson-api-and-jaxb-annotation [here] but get an javax.xml.bind.PropertyException.. details
  • You could do the following with CODETERM2 (see: URL_http://blog.bdoughan.com/2010/09/jaxb-collection-properties.html [ URL_http://blog.bdoughan.com/2010/09/jaxb-collection-properties.html ] ): CODESNIPPET_JAVA2 .. details
  • For More Information** URL_http://blog.bdoughan.com/2013/03/binding-to-json-xml-handling-collections.html [ URL_http://blog.bdoughan.com/2013/03/binding-to-json-xml-handling-collections.html ] URL_http://blog.bdoughan.com/2013/06/moxy-is-new-default-json-binding.html [ URL_http://blog.bdoughan.com/2013/06/moxy-is-new-default-json-binding.html ] .. details
  • Problems with Your Model There are a few problems with your model: Getter with no Setter** By default JAXB Will not consider a get method without a corresponding set method as a property.. details
  • Solution to Both Problems Instead of using the default property access, you can use the CODETERM2 annotation to tell JAXB to use field access.. details
  • You can't blame me or my answer for the existence of a disagreement between jaxb and jackson.. details
  • JAXB cant handle non-static inner classes.. details
  • Can't you tell me, what's wrong with that approach?. details
  • Is there a way to map JAXB Objects into JSON with some other means, but which will follow the whole JAXB specification so that I have no problems in the future converting from JSON to the JAXB object and visa vera?. details
  • Is there a way to map JAXB Objects into JSON with some other means, but which will follow the whole JAXB specification so that I have no problems in the future converting from JSON to the JAXB object and visa vera?. details
  • But when I try to convert the JSON back into the JAXB object, it throws an exception connected somehow with the JAXBElement.. details
  • For More Information** URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html [ URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html ] MOXy as the Default JSON-Binding Provider in Jersey/GlassFish If you are using MOXy as the default JSON-binding provider with Jersey/GlassFish you can leverage the CODETERM11 class as follows: CODESNIPPET_JAVA3 .. details
  • For More Information** URL_http://blog.bdoughan.com/2013/06/moxy-is-new-default-json-binding.html [ URL_http://blog.bdoughan.com/2013/06/moxy-is-new-default-json-binding.html ] .. details
  • By default CODETERM9 is configured not to include the root element.. details
  • As seen here, the 'element' tag is lost in the json.. details
  • I'm using JAXB 2.2.5 rather than MOXy for class generation, the full source code for schema generation is available from URL_http://svn.musicbrainz.org/mmd - schema/trunk/brainz-mmd2-jaxb/ (note the last checkin of DiscList contains a manually modified propOrder, my fix before I saw yours).. details
  • EDIT**:This is what Fiddler captures when I post the JSON data: CODESNIPPET_JAVA7 .. details
  • Unfortunately I cannot use the @XmlElement option because beginDate is an attribute not an element and already has a @XmlAttribute annotation, and this does not seem to support nillable.. details
  • but that is not what I want Update with attempt to use Denises answer** I've ran into a few problems with the proposed solution, first here is the full Alias class I think that would help (note the classes autogenned with JAXB, I came across this before ElipseLink and because my Xml output is okay Im not particulary keen to change this) CODESNIPPET_JAVA4 .. details
  • So i then edited Alias.java to add beginDate to propOrder, but this gave this error.. details
  • So i then edited Alias.java to add beginDate to propOrder, but this gave this error.. details
  • Oh I see, the problem is you can have more than one relation-list element (with a different type attribute), so instead of there being a RelationList element, there isd a list of RelationList elements URL_http://svn.musicbrainz.org /mmd-schema/trunk/brainz- mmd2-jaxb/src/main/java/org/musicbrainz/mmd2/Work.java right well least I can see the problem now.. details
  • The actual model is a little more complex then Ive posted but the additional elements dont seem relevant to the issue.. details
  • Unfortunately it doesn't work.. details
  • BTW, if it wasn't clear, the annotations above are standard JAXB which JAX-RS implementations should follow.. details
  • jaxb.properties To specify MOXy as your JAXB provider you need to include a file called CODETERM1 in the same package as your domain model with the following entry (see: URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as- your.html [ URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as - your.html] ): CODESNIPPET_JAVA2 .. details
  • jaxb.properties To specify MOXy as your JAXB provider you need to include a file called CODETERM1 in the same package as your domain model with the following entry (see: URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as- your.html [ URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as - your.html] ): CODESNIPPET_JAVA2 .. details
  • It's a shame that JAXB can't see the setter if it's defined in the super class.. details
  • If you are using the URL_http://jersey.java.net/nonav/documentation/latest/jso n.html#json.jaxb.approach.section [JAXB] approach, you can mark fields with CODETERM1 to omit them.. details
  • If you are using the URL_http://jersey.java.net/nonav/documentation/latest/jso n.html#json.jaxb.approach.section [JAXB] approach, you can mark fields with CODETERM1 to omit them.. details
  • Could be but I think here the problem is ahead, I am not hitting the service at all.. details
  • Could be but I think here the problem is ahead, I am not hitting the service at all.. details
  • If the above plugin doesn't do exactly what you want (which I think it should, it looks pretty flexible), it shouldn't be too difficult to roll your own modification (I have done this before for adding copy constructors to generated classes).. details
  • The key names in JSON will differ on the basis of annotation provided.. details
  • error.. details
  • JAXB (JSR-222) is configuration by exception and only requires annotations where you need to override the default XML representation (Jettison converts XML StAX events to/from JSON).. details
  • jaxb.properties To specify MOXy as your JAXB provider you need to include a file called CODETERM1 in the same package as your domain model with the following entry (see: URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as- your.html [ URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as - your.html] ): CODESNIPPET_JAVA3 .. details
  • jaxb.properties To specify MOXy as your JAXB provider you need to include a file called CODETERM1 in the same package as your domain model with the following entry (see: URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as- your.html [ URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as - your.html] ): CODESNIPPET_JAVA3 .. details
  • I am getting the following Exception when I try to marshall the java object to Json CODESNIPPET_JAVA1 .. details
  • I'm concerned that the manner in which i annotate the getter method might be affecting the overall bean as it's passed to the server?. details
  • Mapper transfers it logically to: The JAXB specification** itself does not cover JSON-binding so sometimes implementations are used with libraries like Jettison which converts XML events to/from JSON and problems occur such as collections of size 1 being represented incorrectly.. details
  • FYI WebLogic switched to MOXy as the default JAXB provider: URL_http://blog.bdoughan.com/2011/12/eclipselink-moxy-is-jaxb - provider-in.html.. details
  • Thanks for this very detailed reply, sorry I should have replied earlier but havent quite understood if it will do what I want.. details
  • Thanks for this very detailed reply, sorry I should have replied earlier but havent quite understood if it will do what I want.. details
  • BTW String is also an Object so your Android client (about which you should give some info if that is the problem) should work.. details
  • BTW String is also an Object so your Android client (about which you should give some info if that is the problem) should work.. details
  • BTW String is also an Object so your Android client (about which you should give some info if that is the problem) should work.. details
  • But I think, that it's wrong, when object converts to String.. details
  • DEMO CODE** _**jaxb.properties**_ To specify MOXy as your JAXB provider you need to include a file called CODETERM6 in the same package as your domain model with the following entry (see: URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as- your.html [ URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as - your.html] ): CODESNIPPET_JAVA4 .. details
  • DEMO CODE** _**jaxb.properties**_ To specify MOXy as your JAXB provider you need to include a file called CODETERM6 in the same package as your domain model with the following entry (see: URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as- your.html [ URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as - your.html] ): CODESNIPPET_JAVA4 .. details
  • Converting JSON to XML and vice versa using Jackson API and JAXB Annotation.. details
  • JAXB is for XML, are you confusing it with JAX-RS?. details
  • There do appear to be URL_http://sourceforge.net/projects/jaxb-builder/ [Eclipse-tools] that automate this manual drudgery.. details
  • When you want the shallow fetch, use the default fetch plan and make your returned object transient, e.g.. details
  • I suspect this has something to do with the fact that CODETERM6 is a list rather than a single value.. details
  • Actually I don't think his problem is really that: if you look carefully at JSON sample he is showing, the multi-object case, there is the bigger issue of content being a String, not JSON.. details
  • Actually I don't think his problem is really that: if you look carefully at JSON sample he is showing, the multi-object case, there is the bigger issue of content being a String, not JSON.. details
  • @StaxMan his issue is that he wants to force the parsing of JSON into complex objects and he is having issues.. details
  • @StaxMan his issue is that he wants to force the parsing of JSON into complex objects and he is having issues.. details
  • FWIW, this way (of applying to elements) was heavily influenced by JAXB, which has this behavior.. details
  • For More Information** URL_http://blog.bdoughan.com/2010/11/jaxb-and-inheritance-using-substitution.html [ URL_http://blog.bdoughan.com/2010/11/jaxb-and-inheritance-using-substitution.html ] QUESTION 2 Second, is there a way to get rid of "bird", "cat", and "dog"?. details
  • For More Information** URL_http://blog.bdoughan.com/2010/11/jaxb-and-inheritance-using-substitution.html [ URL_http://blog.bdoughan.com/2010/11/jaxb-and-inheritance-using-substitution.html ] QUESTION 2 Second, is there a way to get rid of "bird", "cat", and "dog"?. details
  • Ok, I'm a little embarrassed - adding the dependency does fix the problem and I don't know why I didn't test it before!. details
  • Ok, I'm a little embarrassed - adding the dependency does fix the problem and I don't know why I didn't test it before!. details
  • Key By specifying CODETERM2 the contents of the reference object are pulled up into the node corresponding to the source object.. details
  • The error: CODESNIPPET_JAVA1 .. details
  • (At the bottom you can find the error message, the WS, the objects & the xsd for one example) Thanks in advance.. details
  • I think there's some type confusion in getJAXBContext().. details
  • Related Bug** URL_http://bugs.eclipse.org/372276 [ URL_http://bugs.eclipse.org/372276 ] Recommended Fix** If you add a new mapping in the external mapping file (which is a bit rare since you would have had to explicitly remove the mapping via annotations - URL_http://blog.bdoughan.com/2012/04/jaxb-and-unmapped-properties.html [ URL_http://blog.bdoughan.com/2012/04/jaxb-and-unmapped-properties.html ] ).. details
  • I would like to see if there is an actual bug here.. details
  • MOXy uses the same XJC code as the reference implementation and the JAXB RI also throws an exception if the CODETERM3 is incomplete so I'm not sure what scenario would have excluded it.. details
  • This best mechanisms for this are: EclipseLink Forum: URL_http://www.eclipse.org/forums/index.php?t=thread&frm_id=111 [ URL_http://www.eclipse.org/forums/index.php?t=thread&frm_id=111 ] EclipseLink Users Mailing List: eclipselink-users AT eclipse.org** Enter a Bug: URL_https://bugs.eclipse.org/bugs/enter_bug.cgi?product=EclipseLink [ URL_https://bugs.eclipse.org/bugs/enter_bug.cgi?product=EclipseLink ] For More Information** URL_http://blog.bdoughan.com/2010/12/extending-jaxb-representing-annotations.html [ URL_http://blog.bdoughan.com/2010/12/extending-jaxb-representing-annotations.html ] UPDATE Thanks for the answer although I'm not convinced requiring me to add element to prop order just because I want to rename it is an improvement.. details
  • Json Response String is {"0":{"0":"Rockey","1":"John"}} I am using Apache CXF Framework with Jettison as the JSON Provider also uses JAXB to wire the data to low bandwidth clients.. details
  • One that we can use internally and one that we will expose externally.. details
  • What can I do to solve my problem?. details
  • What can I do to solve my problem?. details
  • Problem was in the xjb file, for details look in the related question URL_http://stackoverflow.com/questions/12860742/jaxb-bean-generation [here] .. details
  • The default Jersey Jackson provider is configured to use JAXB annotations alongside Jackson ones ;-) The only issue is that the exact configuration of this provider is not documented :-(.. details
  • Maybe the stack trace holds the solution Update The full project is available online The data model is at URL_http://svn.musicbrainz.org/mmd-schema/trunk/brainz- mmd2-jaxb/ [ URL_http://svn.musicbrainz.org/mmd-schema/trunk/brainz-mmd2-jaxb/ ] Download and run mvn install Then the project that uses this is at URL_http://svn.musicbrainz.org/search_server/trunk/ [ URL_http://svn.musicbrainz.org/search_server/trunk/ ] Download and run mvn package, This contains three subprojects and the problem one is the servlet project, to replicate the issue: cd servlet Edit src/main/resources/oxml.xml changing CODESNIPPET_JAVA8 .. details
  • So essentially I want to merge all the relations so they are in one list and lose the relationlist label.. details
  • mvn package src/test/java/org/musicbrainz/search/servlet/FindWorkTest will now fail ontestOutputAsJsonNew() and testOutputAsJsonNewPretty() Further Update**Blaise worked out the problem the example doesn't show (and I wasn't aware) that you can actually have multiple relationList elements, i.e the Xml could be CODESNIPPET_JAVA10 .. details
  • In my example I'm using MOXy's default reprentation of CODETERM3 .. details
  • Many libraries incorrectly treat collections of size 1 as JSON objects.. details
  • The CODETERM4 element is a complex type with simple content (see: URL_http://blog.bdoughan.com/2011/06/jaxb-and-complex-types-with-simple.html [ URL_http://blog.bdoughan.com/2011/06/jaxb-and-complex-types-with-simple.html ] ).. details
  • The CODETERM4 element is a complex type with simple content (see: URL_http://blog.bdoughan.com/2011/06/jaxb-and-complex-types-with-simple.html [ URL_http://blog.bdoughan.com/2011/06/jaxb-and-complex-types-with-simple.html ] ).. details
  • You can see full mavenized project at URL_http://code.google.com/p/jinahya/sou rce/browse/trunk/com.googlecode.jinahya/stackoverflow/ [ URL_http://code.google.com /p/jinahya/source/browse/trunk/com.googlecode.jinahya/stackoverflow/] JAXB doesn't need the setter if you control to use fields not properties.. details
  • You can see full mavenized project at URL_http://code.google.com/p/jinahya/sou rce/browse/trunk/com.googlecode.jinahya/stackoverflow/ [ URL_http://code.google.com /p/jinahya/source/browse/trunk/com.googlecode.jinahya/stackoverflow/] JAXB doesn't need the setter if you control to use fields not properties.. details
  • But the actual requirement is a more complex transformation, Im not sure how to explain it in the correct terminology but here is an example of the required output.. details
  • But the actual requirement is a more complex transformation, Im not sure how to explain it in the correct terminology but here is an example of the required output.. details
  • jaxb.properties To specify MOXy as your JAXB provider you need to include a file called CODETERM7 with the followin entry (see URL_http://blog.bdoughan.com/2011/05 /specifying-eclipselink-moxy-as-your.html [ URL_http://blog.bdoughan.com/2011/05 /specifying-eclipselink-moxy-as-your.html] ): CODESNIPPET_JAVA4 .. details
  • jaxb.properties To specify MOXy as your JAXB provider you need to include a file called CODETERM7 with the followin entry (see URL_http://blog.bdoughan.com/2011/05 /specifying-eclipselink-moxy-as-your.html [ URL_http://blog.bdoughan.com/2011/05 /specifying-eclipselink-moxy-as-your.html] ): CODESNIPPET_JAVA4 .. details
  • _**One Line**_ By default when you include CODETERM3 in your JAX-RS application, the output will be marshalled on one line: CODESNIPPET_JAVA6 .. details
  • By default URL_http://www.eclipse.org/eclipselink/moxy.php [EclipseLink- JAXB-(MOXy)] will marshal the JSON to one line.. details
  • To solve another problem I have moved from using Jersey to EclipseLink MOXy to generate JSON from a JAXB created object model ( created by Sun JAXB 2.1.12).. details
  • jaxb.properties To specify MOXy as your JAXB provider you need to include a file called CODETERM2 in the same package as your domain model with the following entry (see ): CODESNIPPET_JAVA3 .. details
  • Do I dispense with all the custom mapping information and just use JAXB or Spring OXM?. details
  • The CODETERM2 is deprecated, is there any other way of solving this problem?. details
  • The CODETERM2 is deprecated, is there any other way of solving this problem?. details
  • MapAdapter An CODETERM4 allows you to marshal an instance of one class as an instance of another class (see: URL_http://blog.bdoughan.com/2010/07/xmladapter-jaxbs- secret-weapon.html [ URL_http://blog.bdoughan.com/2010/07/xmladapter-jaxbs-secret - weapon.html] ).. details
  • For More Information** URL_http://blog.bdoughan.com/search/label/XmlAdapter [ URL_http://blog.bdoughan.com/search/label/XmlAdapter ] URL_http://blog.bdoughan.com/2012/04/binding-to-json-xml-handling-null.html [ URL_http://blog.bdoughan.com/2012/04/binding-to-json-xml-handling-null.html ] I noticed that you had the following comment in your code: // getters and setters with @XmlElement on each attribute Because JAXB (JSR-222) implementations are configuration by exception, you only need to add annotations where you want the XML representation from the default.. details
  • For More Information** URL_http://blog.bdoughan.com/search/label/XmlAdapter [ URL_http://blog.bdoughan.com/search/label/XmlAdapter ] URL_http://blog.bdoughan.com/2012/04/binding-to-json-xml-handling-null.html [ URL_http://blog.bdoughan.com/2012/04/binding-to-json-xml-handling-null.html ] I noticed that you had the following comment in your code: // getters and setters with @XmlElement on each attribute Because JAXB (JSR-222) implementations are configuration by exception, you only need to add annotations where you want the XML representation from the default.. details
  • Our use case was more complex with DTOs, JPA entities, versioning etc.. details
  • JAXB implementations have default rules for mapping field/property names, but since your document differs from the default each field had to be annotated.. details
  • As a side note, if I add JAXB annotations to my entities (@XmlRootElement on MyFooCollectionWrapper and MyFooDTO) the using the same webResource get call, the client I do not get a message body reader exception, however, the response is marshaled such that MyFooCollectionWrapper looks ok but its collection does not contain a MyFooDTO it contains an XML Document with the proper values in the nodes/attrs - in other words MyFooDTP doesn't get marshaled.. details
  • I'm re-asking an unanswered question from the now read-only google groups App Engine for Java because I have the exact same problem.. details
  • It works _almost_ fine, however the _first_ request to the server always ends up with the exception: java.lang.NoClassDefFoundError: org/codehaus/jackson/xc/JaxbAnnotationIntrospector For some reason gae/jersey cannot find this class on the initial request.. details
  • Additional Information as Requested**The json is generated from this MMD schema URL_http://svn.musicbrainz.org/mmd-schema/trunk/brainz-mmd2-jaxb/src/main/resources/musicbrainz_mmd-2.0.xsd [ URL_http://svn.musicbrainz.org/mmd-schema/trunk/brainz-mmd2-jaxb/src/main/resources/musicbrainz_mmd-2.0.xsd ] using JAXB and Jersey , see URL_http://svn.musicbrainz.org/search_server/trunk/servlet/src/main/java/org/musicbrainz/search/servlet/mmd2/ResultsWriter.java [ URL_http://svn.musicbrainz.org/search_server/trunk/servlet/src/main/java/org/musicbrainz/search/servlet/mmd2/ResultsWriter.java ] and URL_http://svn.musicbrainz.org/search_server/trunk/servlet/src/main/java/org/musicbrainz/search/servlet/mmd2/ArtistWriter.java [ URL_http://svn.musicbrainz.org/search_server/trunk/servlet/src/main/java/org/musicbrainz/search/servlet/mmd2/ArtistWriter.java ] The point is that I want to be able to generate Json and XML from one schema with the minimum of fuss, but apparently the Json doesn't look right so Im looking for a way to improve it (I don't really have any experience of json myself) .. details
  • I followed the instructions URL_http://www.mkyong.com/webservices/jax-rs/json- example-with-jersey-jackson/ [here] which show how to use Jersey and Jackson POJOs(as opposed to JAXB).. details
  • Below is an example of how the CODETERM1 annotation can be leveraged to map your use case: Foo By default a JAXB implementation will not marshal a null property.. details
  • By default, Jersey is using JAXB for the (un)marshalling process, and unfortunately, JAXB JSON processor is not standard (_one-element arrays are ignored, empty arrays are transformed into a one-element empty array..._).. details
  • You can use a Provider to change default behaviour of JSONJAXBContext.. details
  • For More Information** URL_http://blog.bdoughan.com/2012/03/moxy-as-your-jax-rs-json-provider_15.html [MOXy-as-Your-JAX-RS-JSON-Provider---Client-Side] URL_http://blog.bdoughan.com/2012/03/moxy-as-your-jax-rs-json-provider.html [MOXy-as-Your-JAX-RS-JSON-Provider---Server-Side] URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as-your.html [Specifying-EclipseLink-MOXy-as-Your-JAXB-Provider] UPDATE In GlassFish 4 EclipseLink JAXB (MOXy) is the default JSON-binding provider used by Jersey: URL_http://blog.bdoughan.com/2013/06/moxy-is-new-default-json-binding.html [ URL_http://blog.bdoughan.com/2013/06/moxy-is-new-default-json-binding.html ] .. details
  • For More Information** URL_http://blog.bdoughan.com/2012/03/moxy-as-your-jax-rs-json-provider_15.html [MOXy-as-Your-JAX-RS-JSON-Provider---Client-Side] URL_http://blog.bdoughan.com/2012/03/moxy-as-your-jax-rs-json-provider.html [MOXy-as-Your-JAX-RS-JSON-Provider---Server-Side] URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as-your.html [Specifying-EclipseLink-MOXy-as-Your-JAXB-Provider] UPDATE In GlassFish 4 EclipseLink JAXB (MOXy) is the default JSON-binding provider used by Jersey: URL_http://blog.bdoughan.com/2013/06/moxy-is-new-default-json-binding.html [ URL_http://blog.bdoughan.com/2013/06/moxy-is-new-default-json-binding.html ] .. details
  • +1 Ahh...I see you beat me to the punch.. details
  • But unfortunately in the latest version of the api they have dropped xml support and only return json.. details
  • I found JAXB is too "fat" for my needs.. details
  • I have an XSD file with enumeration in lower case e.g.. details
  • The problem I had with this is, that the types you give to the JSONJAXBContext need to have a no-arg constructor.. details
  • The problem I had with this is, that the types you give to the JSONJAXBContext need to have a no-arg constructor.. details
  • Doh - sorry, when making the example - I messed up the code trying to make it simpler (should have been setBiz).. details
  • Or do the more common trick of just using a string and don't worry about trying to magically hook everything up in the binding layer.. details
  • Adding layers between the two (such as manually handling data binding) can help but is more work.This is not unique to JSON (XML data binding with libs like JAXB has similar challenges), or even data formats: Hibernate and other ORM libs can also add more close-coupling.Another potential challenge is that of losing visibility into what is happening: data binding is often a black box, and when things work, that's great (fewer things to worry about), but when they don't trouble-shooting may be more difficult.. details
  • Someone suggested a way to solve my problem (in URL_http://stackoverflow.com/questions/5881058/how-to-map-a-bean-structure-to-a -different-schema-with-jax-rs), although it requires using Eclipselink Moxy, which I don't want to introduce (additional dependency and jaxb replacement in whole application).. details
  • This would not occur with Jackson annotations; and ideally not if you combine Jackson and JAXB annotations (I thought Jersey enabled both).If Jackson annotation processing is also enabled, adding @JsonProperty next to 'getBiz' should also do the trick.. details
  • It should work as you show; with one possible exception: if you enable JAXB annotations (only), JAXB restrictions mandate that only getter/setter pairs are used to detect properties.So try adding setter for 'biz' and see if that changes it.. details
  • and class that represents "gadget" model (annotated with @XmlRootElement for JAXB processing): CODESNIPPET_JAVA2 .. details
  • When I do it, I get error: java.lang.IllegalStateException: Invalid JSON namespace: URL_http://www.w3.org/2001/XMLSchema-instance [ URL_http://www.w3.org/2001 /XMLSchema-instance] Specifically, I have a "Wrapper" class with a "result" field of type SuperClass but it will always be an instance of some sub class ("SubClass" below).. details
  • If I make my Wrapper class have its "result" field defined as subclass type "SubClass" it works OK, but when it is of type "SuperClass" but the instance of of SubClass I get the error.. details
  • But for JSON I get the following exception: SEVERE: Mapped exception to response: 500 (Internal Server Error) javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: A message body writer for Java class java.util.Arrays$ArrayList, and Java type java.util.List, and MIME media type application/json was not found I use Jersey 1.6 and, according to the tutorial, JSON format should work with JAXB without any additional programming.. details
  • What's wrong?. details
  • But for JSON I get the following exception: SEVERE: Mapped exception to response: 500 (Internal Server Error) javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: A message body writer for Java class java.util.Arrays$ArrayList, and Java type java.util.List, and MIME media type application/json was not found I use Jersey 1.6 and, according to the tutorial, JSON format should work with JAXB without any additional programming.. details
  • I get the following error with JSON: CODESNIPPET_JAVA2 .. details
  • Problem is: an "issue" has a "summary" property and a list of fields.. details
  • Problem is: an "issue" has a "summary" property and a list of fields.. details
  • On the other hand, if you're using the Jersey JSON plugin, you'd have to write a subclass of CODETERM2 , and add JAXB annotations to it - kind of a pain in the ass.. details
  • Setting the CODETERM1 object to be a JAXB annotated class should solve the problem.. details
  • By default Jersey will use JAXB to process the JSON messages by leveraging the URL_http://jettison.codehaus.org/ [Jettison] library.. details
  • I've tried out Jackson but the problem is that its a major rewrite for us since we're so dependent on our JAXB annotations.. details
  • I've tried out Jackson but the problem is that its a major rewrite for us since we're so dependent on our JAXB annotations.. details
  • Output of project.json (see nested technologies list): CODESNIPPET_JAVA4 .. details
  • Do you guys have any idea what the problem might be?. details
  • it's really frustrating and I've been fighting with this issue for almost 5 hours now... :( I'd expect JAXB/Jersey to embed my list of downloads in the Project's Json Feed... but unfortunately it's completely missing.. details
  • I can fetch the Download object itself without any problems... CODESNIPPET_JAVA2 .. details
  • You can leverage the @XmlPath extension in EclipseLink JAXB (MOXy) to break the relationship between then entity model and the message format (I'm the MOXy tech lead): URL_http://stackoverflow.com/questions/4889913/jaxb2-mapping-nested-elements-into-the-same-java-class/4890120#4890120 [JAXB2:-Mapping-nested-elements-into-the-same-Java-class] .. details
  • Is there a better way to decouple these without subjecting yourself to tedious translation/conversion classes?. details
  • However, this always bothered me because it throughly ties your interface and messages with the structure and design of your data model.. details
  • At low level, what is needed to make sure that ObjectMapper does NOT use JAXBAnnotationIntrospector, but only default JacksonAnnotationIntrospector.. details
  • Ok, no solution found with Jettison (I'm convinced it's a bug) and JAXB mapping for JSON.. details
  • I assume it comes from a wrong JAXB mapping on SearchResults class but can't figure how to correct it (and it's complicated with the JSON translation to XML).. details
  • I'm a bit new to use JSON format manipulation and not very experimented in JAXB either.What I try to do is building a small client to launch search on Twitter.. details
  • I'm trying to force brackets on lists that contain only one element.. details
  • JAXB JSON force brackets on arrays.. details
  • This may cause data loss because of differences in data model between XML and JSON.. details
  • What am doing wrong here?. details
  • For best compatibility 1.6.1 has some further improvements to reduce warnings during initialization (used to complain about missing javax.xml and Joda classes, not any more) .. details
  • Sorry this is such a sketchy question, but as I say, I'm just startingout, and terminology is a problem for me at this stage!. details
  • But I'm struggling to understand how to make an employeea member of a team at creation-time by just passing in a Team ID, ratherthan passing in a nested team object in my JSON object.. details
  • Sorry this is such a sketchy question, but as I say, I'm just startingout, and terminology is a problem for me at this stage!. details
  • So we find a painful way of checking each field in the car object and if they are null, then set the car as null, so jackson jaxb provider can render it as null.. details
  • So we find a painful way of checking each field in the car object and if they are null, then set the car as null, so jackson jaxb provider can render it as null.. details
  • Default setting is false, meaning root value is not wrapped.. details
  • Since I am more familiar with Jackson, here are some aspects where I think Jackson has more complete support than Gson (apologies if I miss a Gson feature): Extensive annotation support; including full inheritance, and advanced "mix-in" annotations (associate annotations with a class for cases where you can not directly add them) Streaming (incremental) reading, writing, for ultra-high performance (or memory-limited) use cases; can mix with data binding (bind sub-trees) -- EDIT latest versions of Gson also include streaming reader Tree model (DOM-like access); can convert between various models (tree <-> java object <-> stream) Can use any constructors (or static factory methods), not just default constructor Field and getter/setter access (earlier gson versions only used fields, this may have changed) Out-of-box JAX-RS support Interoperability: can also use JAXB annotations, has support/work-arounds for common packages (joda, ibatis, cglib), JVM languages (groovy, clojure, scala) Ability to force static (declared) type handling for output Support for deserializing polymorphic types (Jackson 1.5) -- can serialize AND deserialize things like List correctly (with additional type information) Integrated support for binary content (base64 to/from JSON Strings) .. details
  • Since I am more familiar with Jackson, here are some aspects where I think Jackson has more complete support than Gson (apologies if I miss a Gson feature): Extensive annotation support; including full inheritance, and advanced "mix-in" annotations (associate annotations with a class for cases where you can not directly add them) Streaming (incremental) reading, writing, for ultra-high performance (or memory-limited) use cases; can mix with data binding (bind sub-trees) -- EDIT latest versions of Gson also include streaming reader Tree model (DOM-like access); can convert between various models (tree <-> java object <-> stream) Can use any constructors (or static factory methods), not just default constructor Field and getter/setter access (earlier gson versions only used fields, this may have changed) Out-of-box JAX-RS support Interoperability: can also use JAXB annotations, has support/work-arounds for common packages (joda, ibatis, cglib), JVM languages (groovy, clojure, scala) Ability to force static (declared) type handling for output Support for deserializing polymorphic types (Jackson 1.5) -- can serialize AND deserialize things like List correctly (with additional type information) Integrated support for binary content (base64 to/from JSON Strings) .. details
  • The problem is that when I am trying to use the same for un-marshalling my request it doesnt work.. details
  • Ok, i just figured your case was more complex than i though.... details
  • Works nicely with Jersey, and I am use it myself (current Jersey version does not bundle full Pojo data binding by default, but will in near future) I would actually not use any of xml libs to produce "json": XStream and JAXB/Jettison can produce kind of JSON, but it uses ugly conventions that are rather non-intuitive.. details
  • EDIT (18-Jul-2011): Jackson actually has an extension called " URL_https://github.com/FasterXML/jackson-xml-databind [jackson-xml-databind] " that can read/write XML, similar to JAXB.. details
Summaries the opinions about javax.xml using topic modeling.
  • 0. jersey jaxb resource strat media employee pojo jackson simple bind: 21
    • Thanks for the answer, in this third solution, the example code which is used isColumnPositionMappingStrategy strat new ColumnPositionMappingStrategy();strat.setType(YourOrderBean.class);String[] columns new String[] {"name", "orderNumber", "id"}; // the fields to bind do in your JavaBeanstrat.setColumnMapping(columns);CsvToBean csv new CsvToBean();List list csv.parse(strat, yourReader);what exactly is yourReader here, and how do I input values to bind with bean?. details
    • Dependencies Remove both jersey-media-json (this module doesn't exist any more in Jersey 2.x) and jersey-json (which is only for Jersey 1.x) and add one of the modules jersey-media-moxy (JAXB) or jersey-media-json-jackson (POJO).. details
    • Demo Code** Below is a standalone example you can run to prove that everything works: CODESNIPPET .. details
    • Jersey is a great JAX-RS framework, EclipseLink provides JAXB & JPA implementations and is not a Jersey replacement.. details
    • Thanks in advance!. details
    • My web application works fine (I'm able to successfully access other resources) but this one resource (that I pass my JSON to) returns a 415 Media Type Unsupported exception.. details
    • Then you will need to override the propOrder in the external mapping file as well.. details
    • and the Resource looks like this: CODESNIPPET .. details
    • Priorities could obviously change if there's enough momentum in that direction, but I just don't see it happening in the next week.. details
    • Demo Below is a standalone example you can run to prove everything works.. details
    • Thanks in advance.. details
    • However, of course, it returns all the Employee attributes in the employees list, like this: CODESNIPPET .. details
    • Therefore, my desired JSON response would look something like this: CODESNIPPET .. details
    • However, all subsequent requests after this work fine, the class then seems to have been loaded.. details
    • We could eliminate this class if your JSON looked like: [{"appName":"ANDROID","totalUsers":"0"},{"appName":"IOS","totalUsers":"4"}] .. details
    • I had a go at creating a schema from the example json I had but didnt get it working for al but the simplest example.. details
    • I really find SimpleXML a good tool, no jar / classpath problems, easy to use (as is JaxB), pretty fast, good error reporting when somethings goes wrong (XML element not mapped for example), and so on.. details
    • @Colin: I just said that Jackson supports JAXB annotations as well.. details
    • The POJO's which represent my resources are JAXB (XML) annotated simple Java classes (they are generated from a schema definition - so they have the annotations).. details
    • Thanks in advance .. details
    • For example, I'd like to be able to call POST /employee/ with a JSON thatlooks like this: CODESNIPPET .. details
  • 1. jaxb implementation jackson moxy binding jax generate simple jersey produce: 30
    • Since it converts StAX events to/from JSON it can be used with an XML binding tool (JAXB is the standard) to produce JSON from objects.. details
    • In the past I remember working with XML files, using the JAXB compiler to automatically generate Java classes, and those tags where automatically generated, so I guess some tools to generate code do this, while others do not.. details
    • @Jaroslaw.zawila I hoped in Jackson there is an annotation like XmlJavaTypeAdapter in jaxb.. details
    • If you used JAXB to generate your classes, you can certainly have something like @XmlElements with different types to parse a List.. details
    • JSON binding with JAXB and Jackson in standalone JavaSE app.. details
    • With the reference JAXB implementation this works fine in both XML and JSON (we were using Jackson for the JSON logic).. details
    • Your implementation is decent enough.. details
    • Thanks, I updated to the code with my Customer class.. details
    • There's a JAXB plugin for adding annotations: You can hook it into the generate-sources phase of a Maven build like so: CODESNIPPET .. details
    • You can use one or two tools for this: one common combination is to use Jackson for JSON, and JAXB for XML, to use their respective strengths.. details
    • The JAXB-(JSR-222) specification does not cover JSON-binding so this type of support is beyond the spec.. details
    • This would be useful as I do not believe what you are seeing is a JAXB issue, but an issue in the JSON binding layer that you are using.. details
    • Update: I confirmed that Day marshalling is indeed working for scalar String properties by adding a scalar List<String> property and observing the expected output in the JSON.. details
    • EclipseLink JAXB (MOXy) offers support for all JAXB constructs in our JSON- binding implementation and it may be a better fit for you use case: Below is a link to some official Jersey examples that leverage MOXy as the JSON provider: .. details
    • The JAXB-(JSR-222) spec does not cover JSON binding so the answer ultimately comes down to how/if your JAX-RS implementation interprets JAXB metadata to produce/consume JSON.. details
    • Below is an example where the same object model is mapped to two different weather services (Google and Yahoo) MOXy also supports both XML and JSON binding: MOXy also integrates easily with JAX-RS implementations: .. details
    • _**Demo**_ MOXy doesn't just interpret JAXB annotations it is a JAXB implementation so the standard JAXB runtime APIs are used.. details
    • EDIT: I guess i'm looking for what produces smaller files and operates faster.. details
    • Since answering these questions will necessarily involve more community input than we've had yet since the project is so new, I was thinking we'd wait until a post-1.0 release to add XML support.. details
    • Now, I also like to generate JSON files after this line.. details
    • Generating more json like json from JAXB and Jersey.. details
    • We have a whole set of JAX-RS REST services running on top of Apache CXF and Jackson.We use JAXB annotations to take care of marshalling POJOs to JSON, works great.. details
    • Jersey uses serialization frameworks like JAXB (xml) and Jackson (json, bson, xml, csv) for actual reading/writing of content.. details
    • As an alternative to Jettison, your original JSON input can be easily parsed with StAXON 's "eclipselink.media-type" , which works with any JAXB implementation: CODESNIPPET .. details
    • If you are ultimately looking for a way to interact with JSON using a JAXB (JSR-222) implementation, then the following is how it can be done using MOXy.. details
    • You can also use JPA annotations on the same objects and a JPA provider like Eclipse Link for a lot of your database needs.. details
    • JAX-RS supports the use of JAXB (Java API for XML Binding) to bind a JavaBean to XML or JSON and vise versa.. details
    • Now: simple solution for most JAX-RS implementations is to not use JAXB annotation based approach at all, but a JSON-specific serializer, such as Jackson 's JacksonJsonProvider (Jackson can actually use JAXB annotations, too).. details
    • Thanks for that but I would prefer to not use any plugs in, I know there is a simple way that I could do it with a simple for each object in the array loop.I had it going before but I cant find it again.. details
    • Not straightforward, but I'd combine JAXB, Jackson and BeanUtils.. details
  • 2. jaxb jackson note output mapping standard jaxbcontext format create produce: 52
    • @chrylis, it's far from trivial to constuct an elaborate java structure which can serialize to both pretty json and pretty xml.. details
    • Normally mapping of JSON to POJOs works with JAXB without creating an own messageBodyReader, because the message reader for JSON already exists.. details
    • Works fine, but I have to do it in this way inside the resource method: JAXBContext context JAXBContextFactory.createContext(new Class[] {ONIXMessage.class}, null); How can I fetch the eclipselink JAXBContext from Jersey?. details
    • yes I see that before sending the request an OPTIONS call is send It's normal now I decided to make it as simple with text/xml and mapped it to objects with jaxb .thanks anyway.. details
    • You basically need to add a provider for JSON support, like f.e.. details
    • So, can I do something like: @GET @Path("/userinfo/{id}") @Produces({"application/xml", "application/json"}) public String getUserInfo(@PathParam("id") String id) {String users null;User user null;user new UserManager().getUserInfo(id); JAXBContext jaxbContext JAXBContext.newInstance(User.class);Marshaller jaxbMarshaller jaxbContext.createMarshaller(); jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);jaxbMarshaller.marshal(user, System.out); users jaxbMarshaller.toString(); return users;} .. details
    • But I feel it like this jaxb thing is not straight forward and it could have been a little easier than the current thing.. details
    • Note too that you need not use JAXB -- JAXB is for producing XML (altough there are impls that do some form of JSON output as well).. details
    • I am unable to download the jar file for import org.eclipse.persistence.jaxb.JAXBContextProperties and import org.eclipse.persistence.jaxb.MarshallerProperties which jar i have to use it will be helpfull if i know the link from where can i get it.. details
    • The simplest way of doing this is to use JAXB to create the tooled version of the structure (with something like Jackson as the serialization engine) and then to create a factory method somewhere that will make the structure for you without you having to specify anything extra yourself.. details
    • Any help would be most appreciated, (de)serialization with JSON and XML with json.org, Jackson, and JAXB has turned into a black and bottomless pit that has consumed almost a month of my life.. details
    • I should clarify, as Perception says, JAXB was originally about mapping between Java and XML, pragmatically may implementations of JAXB also support mapping to to JSON: for example .. details
    • Will result in: { "book" : { "title" : "hello" } } Both org.eclipse.persistence.moxy-2.5.1.jar and org.eclipse.persistence.core-2.5.1.jar are needed on the classpath.While playing around with this myself, I ran into: hottest-JAXB-answers .. details
    • I'm using JAXB and MOXy to unmarshal structure like CODESNIPPET .. details
    • can you please tell me , on what area i can find the overhead between two test.. details
    • I tried to use Jackson with JAXB module to convert JAXB-object into JSON, which works pretty fine with storing the data.. details
    • Given a model object Foo create a JsonFoo and XmlFoo 2) Write a custom message converter I tried this and it turned out to be a bit complicated since the view must know how to resolve e.g., a Foo to a JsonFoo to be able to serialize it into a readable format.. details
    • Is their a good way to export a mixed HashMap list?. details
    • I've fixed the factory method for others to see, I hope you don't mind.. details
    • Ah should have seen this I was looking at my initialcontext method rather than my marshaller initialization, disabled Marshaller.JAXB_FORMATTED_OUTPUT and it now works.. details
    • Thanks, btw I saw your blog before (nice one), when I've tried to search a solution to my issue, I just didn't want to change the json provider right now since I'm at the end of the project sprint.. details
    • JSON OUTPUT** Note how the null value for the lastName key is represented as proper JSON.. details
    • The problem is that it's only working for the String property and not the @XmlJavaTypeAdapters property.. details
    • I'm just putting forward my solution (using JAXB), as I have used it to solve issues like his when I was using the Jackson lib.... details
    • Appendix D.3 of JAXB 2.1 specs says that the conversion to uppercase _must_ be done, hence you probably should hope that json marshaling offers something.. details
    • Send Us Your Feedback** We like to get feedback on changes we make, especially on streams that are still in development.. details
    • Everything is working fine except that the generated responses contain the setters info e.g.. details
    • The stack trace clearly indicated that a JAXB implementation was being used with the JSON and MOXy supports more JAXB annotations than Jackson does.. details
    • Pls Help !!!. details
    • Note how only the standard JAXB APIs are used.. details
    • Things to note about the JSON: The null value is used to represent that the lastName is null.. details
    • Don't return Strings in your methods but Customer objects it self and let JAXB take care of the de/serialization.. details
    • Even though the id field was mapped with @XmlAttribute there are no special indication of this in the JSON message.. details
    • 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.. details
    • In my application the JAXB output generates like: withAnnotationIntrospector(AnnotationIntrospector ai) this is method call to the spring Object XML Mapping Marshallers that generate XML files.. details
    • Note sadly that map-to-json-object-with-jersey-jaxb-jackson [Java.util.Map-to-JSON-Object- with-Jersey-/-JAXB-/-Jackson] was not helpful, though it showed great promise.. details
    • Note that I'm not saying this solution is optimal, just what has worked for us.. details
    • As a simple test, I return a bean of Book, and it gets output as JSON, but the JAXB object (delivery schedule) stays in an XML format.. details
    • So, you've got two choices: 1. configuring JAXB to be more standard ( see-here for more); 2. using Jackson instead of JAXB which I recommend.. details
    • I'm using a JAXB adapter... JAXBDateAdapter that formats my dates in a standard format for the JSON-consuming clients.. details
    • If you are using JAXB in combination with JAX-RS (Java API for RESTful webservices), this is easy.. details
    • I would recommend using Jackson as it is superior to other recommended alternatives when producing JSON, and for XML either: Use a JAXB implementation with JAXB annotations (Jackson can optionally support JAXB annotations as well, so very little overhead of 2 libs) Use Jackson-xml-databind module to produce XML using Jackson itself (in format that is usually identical to JAXB produced) I do NOT think that you absolute must use a single library or framework, and the result is often better if you just choose best choice for each separately.. details
    • Demo The standard JAXB APIs are used to do the conversions to/from JSON and XML: CODESNIPPET .. details
    • GSON from google : , or Jackson the library used in spring : and I would concur with others suggesting jaxb for XML to pojo, well supported lots of tools : its the standard.. details
    • I've used org.w3c.dom.Element maybe using another one may help navigate through the response (if jaxb supports it).. details
    • Finally, Jackson supports JAXB annotations if you must use them (for example, when using JAXB for producing XML).. details
    • This involves creating a JSONJAXBContext like this: CODESNIPPET .. details
    • I think you should be able to just construct ObjectMapper (which does not add JAXB introspector by default), and register it via standard JAX-RS provider mechanism.. details
    • If I change it to String groupName="oneoneoneoneone"; the JSON response will treat it as a Sting and keep the double quotes in the response.. details
    • To support both JSON and XML messages do the following: CODESNIPPET .. details
    • Note that we are already using a JAXB ContextResolver to ensure the JSON is correct for a single row.. details
    • "JAXB-spec-defines-a-special-handling-for-Map-when-it's-used-as-a-property- of-a-bean."]. details
  • 3. jaxb service binding response post answer mapping provide receive return: 30
    • Does JAXB support to receive values (using POST) and saving them to the database but do not returning (using GET) those values?. details
    • @Molly Usually you can do whatever you want with the values you receive and return anything you want, no matter if it's GET or POST.. details
    • Yeah, sometimes it's the answers lower-down on the list that actually end-up working.. details
    • @RSyed - I also have an example on GitHub that you may find helpful: .. details
    • Thank U so much for your response.. details
    • I was struggling with this as well, but this question is similar and the answer works java-class-to-a-json-using-jaxb [Binding-a-Generic-Java-Class-to-a-JSON-using- JAXB] It's a fairly simple answer although I'd struggle to explain why or how it works and doesn't cause the mapping to occur.. details
    • Based on some arbitration parameter let the controller inject the correct serializer CODESNIPPET .. details
    • Adding jackson-xc-1.9.2.jar solve this warrning below java.lang.NoClassDefFoundError: org/codehaus/jackson/xc/JaxbAnnotationIntrospector I hope this helps somebody.. details
    • When the status is equal to deleted the property1 value is not marshalled.. details
    • But, how do I now ensure that the JSON response returns the value as a JavaScript boolean type, instead of a string (i.e.. details
    • Added the context resolver to your client CODESNIPPET .. details
    • Jeff, thanks for the response.. details
    • To pass your specialized JSONJAXBContext to Jersey, you will finally need to implement a JAXBContext ContextResolver: CODESNIPPET .. details
    • The property of type int was correctly marshalled without quotes.. details
    • As you can see the true value appears without quotes: CODESNIPPET .. details
    • any effort put into resolving this issue?. details
    • Any help very gratefully received!. details
    • You can change this behaviour by setting the nillable property on @XmlElement to true.. details
    • Jettison is an interesting library but there are some issue you will encounter using it: Demo Only the standard Java SE APIs are used.. details
    • Many also allow you to use standard object binding methodologies such as JAXB do define your deserialization mappings using annotations.. details
    • I would recommend you to take a look at the following discussion regarding its internals for-serialization [related-post] .. details
    • Maybe I wasn't specifying the MediaType in the invocation of the service ;) thanks.. details
    • I want to receive and emit JSON objects from Java classes like the following: CODESNIPPET .. details
    • Thanks for the response.. details
    • It isn't a generic data modeling framework with flexible bindings.. details
    • My Download class looks pretty much like this (and as I've mentioned already - this works pretty fine when used directly): CODESNIPPET .. details
    • My starting framework is JBoss RESTEasy (JAX-RS implementation) that provides an elegant way to consume Rest services JSON services by mapping JSON to JAXB thru Jettison framework (it works also in the other way if you want to provide REST service and produce JSON from JAXB).. details
    • I want something like this: {"id":"0","industries":[{"id":"0","name":"Technologies"}],"name":"Google Inc."} But I get: {"id":"0","industries":{"id":"0","name":"Technologies"},"name":"Google Inc."} Here is my Entity: CODESNIPPET .. details
    • The response looks like this CODESNIPPET .. details
    • But, instead, I have to pass in something like this: CODESNIPPET .. details
  • 4. question builder solution marshal pojo post enum input true jaxb: 15
    • I think I will modify the question a bit so that it is easy to understand.. details
    • I have a POJO with JAXB annotations, it works well marshalling to xml and json, however, the xml and json are not compatible since the root tag is lost in json.. details
    • I have to be honest though, I really don't like the idea of having to manage an XML file in addition to my POJO to apply the "views".. details
    • It addresses JAXBAnnotationIntrospector and JacksonAnnotationIntrospector as well.... details
    • I tried to get some inputs from the question I posted and-retrieve-json-in-java-code [here] But could not really get any solution.. details
    • Please clarify your question.. details
    • I'm trying to write a code which can take either xml or JSON input and out JSON or XML respectively.. details
    • There have been many questions as to how why list types are not serialising, however I'm questioning what is a good practice to serve a list type of beans in a simple way.. details
    • The object being serialized and de-serialized contains some standard objects that are stored in MySql.. details
    • It will correctly marshal collections of size 1 wrapped as a JSON array.. details
    • or alternatively, modify json marshaling so it will use the enum "value" method instead the enum name?. details
    • (That works rather well in practice.). details
    • I insist on unmarshalling to this structure: CODESNIPPET .. details
    • Thanks, this is the solution - although I would not have understood what to do without many other similar SO Questions/Answers I found :-) I will post the detailed solution in the Question.. details
    • MappedBuilder builder JSONConfiguration.mapped(); builder.arrays("industries"); builder.rootUnwrapping(true); this.context new JSONJAXBContext(builder.build(), Company.class); } .. details
  • 5. jaxb moxy representation eclipselink attribute offer native add binding response: 25
    • I found a blog article from the person you mentionned and it works.. details
    • Then use Jackson, which has JAXB support, by adding all the libraries to your project and adding this configuration: CODESNIPPET .. details
    • Both status() and echo() are working properly.. details
    • I discovered that when I remove the JAXBElement type from the WS, that it works.. details
    • ex: if status != "deleted" -> bind all fields CODESNIPPET .. details
    • The EclipseLink MOXy** implementation of JAXB offers native JSON binding meaning that items like collections of size 1 will be properly converted to JSON.. details
    • Thankyou that works (actually the attribute is ended though there can be an end attribut eas well that I didn't show), thanks again for all your help on this.. details
    • Also note how the type key doesn't contain any special indicator corresponding to it being an XML attribute in the XML representation.. details
    • EclipseLink JAXB (MOXy) offers native JSON-binding (I'm the MOXy lead) with it you could do something like: CODESNIPPET .. details
    • True, the parts of the Javadoc that I omitted above include "This is identical to how JAXB handles type information annotations; and is chosen since it is the dominant use case.. details
    • To get this JSON representation you have mapped your model with the @XmlElementRef annotation which tells JAXB to use the value of the @XmlRootElement annotation as the inheritance indicator.. details
    • Actually no because the json response is not an array of objects but an object which contains an key "dossiers" and a array as the value.. details
    • @TomAnderson - I have entered an enhancement request to support this use case.. details
    • Additionally my API needs to support both XML and JSON.. details
    • In the XML representation id was an attribute, but in the JSON representation there is not need for it to be specially represented.. details
    • I'm using this in a Spring/MVC RESTful application where I need to support both JSON and XML.. details
    • Fundamentally, XML (and by extension JAXB) likes to trace everything back to a single root node/object.. details
    • It seems pretty basic, but I haven't been able to find any examples online (maybe I'm google searching the wrong things).. details
    • You can add the necessary supporting APIs if you are using Java SE 5.. details
    • EclipseLink JAXB (MOXy) provides native JSON-binding support.. details
    • EclipseLink JAXB (MOXy) offers native support for JSON.. details
    • I had similar problem and I resolved it by creating custom JAXBContextResolver and manually specifying which classes are going to play nicely with json serialization: CODESNIPPET .. details
    • your blog is useful!.. details
    • (@XmlElement(nillable=true) Which makes the response look like, CODESNIPPET .. details
    • I tried setting xml element attribute nillable true.. details
  • 6. moxy jaxb attribute binding jax null header eclipselink case mapping: 22
    • I pretty much look for anything you've written when dealing with MOXy or JAXB.. details
    • You simple need add @Produces("application/xml") or headers section with content similar to this: headers {Const.HEADER_CONTENT_TYPE_APPLICATION_JSON} to your @RequestMapping.. details
    • Thank You so much for your reply.. details
    • But actually , I have used this tool first time and I am not able to find the difference, accurately.. details
    • JAX-RS and MOXyJsonProvider MOXy includes an implementation of MessageBodyReader / MessageBodyWriter which makes it easy to configure MOXy as your JSON-binding provider.. details
    • I have opened the following enhancement request to make this use case even easier to handle: .. details
    • Foo You can take advantage of MOXy's path based mapping for this use case.. details
    • Note how the XmlMapper attribute is used on the ObjectMapper element to indicate a null value.. details
    • You may be interested in the JSON support we've added to EclipseLink JAXB (MOXy).. details
    • Below is how you an support your use case with your Student class as annotated with EclipseLink JAXB (MOXy).. details
    • The collect of phone numbers is of size 1 and is correctly bound by square brackets.. details
    • 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.. details
    • JAX-RS Integration** MOXy includes the MOXyJsonProvider class that makes it easy to configure in your JAX-RS application: .. details
    • You could leverage the JSON-Binding and external mapping document in EclipseLink JAXB (MOXy) to support your use case.. details
    • ( java/uImBt6fOhww/discussion%20original [original] ) I have put together a simple json REST service using jersey, jaxb and jackson.. details
    • For EclipseLink-JAXB-(MOXy) 's JSON binding, the correct mapping would be the following.. details
    • I'm open to trying other ContextResolvers/Serializers, but I haven't been able to find one that works, so code examples would be nice.. details
    • I have a JAXBContextResolver (an implementation of ContextResolver) that looks like this: CODESNIPPET .. details
    • Any help would be greatly appreciated.. details
    • Quite honest comparison, regarding your position.. details
    • Summary is not present as an attribute in the received json, but as a value of the "fields" attribute.. details
    • It will by default include null values for properties, although this is configurable in case you want to suppress nulls.. details
  • 7. jaxb model jackson pojo create annotate jersey bean moxy write: 114
    • :-) JAXB is cool, but I think I'd do discription.substring(1, discription.length()-1) before converting JSON into XML just for the output.. details
    • Thanks.. details
    • Great.. details
    • What does your JAXB-annotated model look like?. details
    • Thank you.. details
    • Thank u so much.. details
    • Thanks!. details
    • I've been able to get it working with JAXB, but I'm specifically looking for Jersey POJO writing, not JAXB writing.. details
    • I created a new question for this that I'd like you to answer here: - jersey-1-17-1-using-jaxb This can help others.. details
    • Thanks.. details
    • JAXB is a standard that lets you translate between XML and objects.. details
    • Take a look at the JAX- RS-spec] or Jersey User Guide especially section devoted to JSON ( JAXB- based-JSON-support] ).. details
    • Searching SO and Google for this has not been helpful, and thought I'd bring this to the geniuses at SO for some help.. details
    • That's interesting because it seems to indicate that the only part JAXB plays in this is to lend its annotations and some other interfaces (e.g.. details
    • Thanks.. details
    • I tried it and the XML consisted of one empty tag only, meaning there's something about the POJO model that JAXB doesn't like.. details
    • If you want to , you can create a separate method just like this very simple (if you already have the JAXB libs) the main class CODESNIPPET .. details
    • I would like to use JAXB in a JavaSE standalone application to read and write Json files.I managed to do it for XML files with my snippet below, but I don't understand how to switch to Json: CODESNIPPET .. details
    • can you please give an example.. details
    • and it works.. details
    • EDIT: I now found this setting: USE_GETTERS_AS_SETTERS (default: true) Controls whether "getters" that return Collection or Map types can be used for "setting" values (same as how JAXB API works with XML), so that separate "setter" method is not needed.. details
    • Thanks.. details
    • Thanks!. details
    • Thanks.. details
    • You can change this by setting a configured instance on a JAX-RS Application class like the one below.. details
    • Thanks!. details
    • thanks for the information!. details
    • I hope it help you.. details
    • You are using JAXB annotations so you need to properly configure your ObjectMapper with the correct module; you need the jackson- module-jaxb-annotations] project.. details
    • Update: JAXB annotation are great for interop with XML system, but you should really use Jackson's own annotation if you can.. details
    • It is possible that Jackson will behave similar to Jettison with respect to the JAXB annotations I simply didn't have the time to try it.. details
    • Please help .. details
    • ?thanks .. details
    • i have a class like : CODESNIPPET .. details
    • My jaxb annotated class looks like this: CODESNIPPET .. details
    • Please read this-blog , at the bottom you will find how it's done without @XmlRootElement .Also go through the answers in the post jaxb [No-@XmlRootElement-generated-by-JAXB] .. details
    • I've created a JAXB bean with a few simple fields along with a nested array of other jaxb beans.. details
    • Also note the collection of size one was correctly represented as a JSON array (a problem with some other approaches).. details
    • Thanks that works.. details
    • Since MOXy implements that JAXB (JSR-222) specification you can be confident using it for your XML as well.. details
    • This is how the JAXB works.. details
    • Thank you!. details
    • The point being: JAXB does not have any concept of JSON, so any support for JSON relies on retrofitting JSON to an XML model of the world (StaX).. details
    • Hope it helps.. details
    • I tried it and the XML consisted of one empty tag only, meaning there's something about the POJO model that JAXB doesn't like.. details
    • That's interesting because it seems to indicate that the only part JAXB plays in this is to lend its annotations and some other interfaces (e.g.. details
    • Make a JAXB context resolver like this CODESNIPPET .. details
    • It's almost perfect.. details
    • No, but I'll look into it, thanks!.. details
    • Anyway, thanks for the help.. details
    • Jackson supports a subset of JAXB metadata and does not currently support the JAXBElement class.. details
    • Your JAXB bean is a perfectly reasonable representation of your JSON data.. details
    • and then your method would look like this: CODESNIPPET .. details
    • This code works fine if I transfer a class ( MyClass ) that has @XmlRoolElement Client CODESNIPPET .. details
    • But if I try to transfer a primitive, like String, Integer, Boolean, etc... Client CODESNIPPET .. details
    • Looks like getJAXBContext() in MOXyJSONProvider might not be picking up a context correctly (and thus creating a JAXB context that doesn't know what "eclipselink.media-type" is).. details
    • , but if you change the type of data attribute to String it will look like due to the way Jaxb handles Strings and primitives: CODESNIPPET .. details
    • If you update Jackson to 2.0 it is not deprecated: databind/javadoc/2.0.0/com/fasterxml/jackson/databind/ObjectMapper.html [ - databind/javadoc/2.0.0/com/fasterxml/jackson/databind/ObjectMapper.html] You can see my configuration here (Spring): mappingjackson2httpmessageconverter-in-spring-3-1-2-with-jaxb-annotati [Registrer-MappingJackson2HttpMessageConverter-in-Spring-3.1.2-with-JAXB- annotations] .. details
    • whereas the best I can get it CODESNIPPET .. details
    • For this example I'm just using the standard JAXB (JSR-222) annotations which have are available in the JDK/JRE since Java SE 6.. details
    • EclipseLink JAXB (MOXy)** supports mapping a single object model to both XML and JSON with the same metadata: License Information** How_is_EclipseLink_Licensed.3F DOMAIN MODEL** Below is the domain model we will use for this example.. details
    • Please advise the best pattern for serialising JAXB Lists.. details
    • 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.. details
    • Can I create one class, annotate it with JAXB annotations(for XML support) and declare in web.xml for JSON (Jackson library) support?. details
    • Can I create one class, annotate it with JAXB annotations(for XML support) and declare in web.xml CODESNIPPET .. details
    • With JAXB there are two type's of List supported.. details
    • So to model it, you need something like this: CODESNIPPET .. details
    • So it looks something like this: CODESNIPPET .. details
    • Below is what your object model could look like.. details
    • For JAXB I believe you need to annotate your entity like below: CODESNIPPET .. details
    • Also, you do not have to use JAXB annotations, unless you either want to use JAXB, or another package that can also use them: Jackson, for example, supports its own annotations as well as JAXB ones.. details
    • This manual could be useful for you: /json.html#json.jaxb.approach.section [link] .. details
    • The JAXB-annotated model class is like this: CODESNIPPET .. details
    • For more information on StAXON's JAXB support, refer to the Using-JAXB wiki page.. details
    • Thanks to serialization-of-a-list-of-jaxb-objects-to-json/3143214#3143214 [How-can-I -customize-serialization-of-a-list-of-JAXB-objects-to-JSON?]. details
    • Given a class like this: CODESNIPPET .. details
    • I prefer JAXB and work with Lists which include extra POJOs.. details
    • Looks like you are making use of JAXB for XML and Jackson for JSON.. details
    • I have a class User that has a createdOn field and it's annotated with XmlJavaTypeAdapter(JAXBDateAdapter.class) When I return any User object from my resources, everything is fine.. details
    • Thanks.. details
    • I have a class that has JAXB and bean validation annotations, much like the following: CODESNIPPET .. details
    • Thanks!. details
    • MOXy does look like a very promising candidate in XML space -- giving JAXB RI and XStream run for their money.. details
    • You then need to work out whether the URI refers to something you know (i.e., resolve the URI and see if it points into yourself) and deal with the fragment identifier.. details
    • Apache Jersey has decent JAXB support.. details
    • In addition to the JAXB annotations MOXy extensions (such as @XmlPath) are supported making it even easier to have one annotated model that can be used for both XML and JSON: .. details
    • It seems to have good JAXB support out of the box.. details
    • Which Java JSON libraries make good reuse of JAXB annotations?. details
    • I am developing a project that already uses XML serialization, so I need an elegant solution to support JSON, by reusing the JAXB annotations.. details
    • Can anyone recommend some Java JSON libraries that makes a good reuse of JAXB annotations?Lightweight libraries are preferred.. details
    • The above example works, so, please, be more precise.. details
    • Something like CODESNIPPET .. details
    • I don't know very well JaxB, and indeed both libraries are pretty close (with the big advantage of the "standardization" for JaxB).. details
    • please specify your question more... you might want to have a look at JAXB.. details
    • Thanks.. details
    • Skaffman, I've tried registering a JAXB annotation introspector following the spec ( ) but I don't see how to dynamically plug that into my restful framework (RESTEasy).. details
    • POJO to XML** JAXB is the Java standard ( JSR-222 ) for converting Java objects to/from XML (I am a member of the JAXB expert group): POJO to JSON** People have been using JAXB with Jettison to produce JSON.. details
    • When I use a list of Strings - everything works perfectly fine!. details
    • Given an entity pojo, I can annotate it with Hibernate, JAXB and JSON annotations so that the same class can be written to the database as well as serialize/deserialize for message exchange.. details
    • It also supports- JAXB-annotations] just like Jettison.. details
    • The Java class could look like the one below.. details
    • In fact I find more clean to avoid this JSON to JAXB translation my first solution was using.. details
    • Rather it is due to whatever processes JAXB annotations, and how it chooses to handle null values of Java objects.. details
    • I'd recommend JAXB + Jackson.. details
    • Thanks!. details
    • I want it to be like, CODESNIPPET .. details
    • Since this has to do with Jersey the first thing I would recommend is to avoid JAXB all together since JAXB (in context of XML or JSON) ain't HATEOAS.. details
    • It has support for JAXB annotations so you would be able to work with JSON and beans generated.. details
    • All good so far.. details
    • There are several ways to parse JSON with it: Streaming (like Sax) Tree (like DOM) Object-mapped (like JAXB) EDIT: Take org.json classes, there are already-in the android API.. details
    • I hope it helps you... .. details
    • I am successfully marshaling a POJO into JSON using JAX-RS and JAXB annotations.. details
    • You only need something like this in your ressources (supposing DetailProduit is your object you want to serialize and that DetailProduit.java is jaxb tagged and in package.of.your.model) CODESNIPPET .. details
    • For POJO to XML I suggest using JAXB (there are other libraries as well, such as XStream for example, but JAXB is standardized).. details
  • 8. jaxb pojo create boolean null simple jettison suggestion change contentusing: 21
    • Also, since content has an @XmlValue annotation in the oxm.xml for the JSON binding it can be changed to be handled instead as a regular element (and name it value or whatever you want to call it).. details
    • I still wonder if there is an even simpler way!.. details
    • thanks your suggestion of changing it to Boolean worked.. details
    • Fantastic, got it working as per suggestion.. details
    • @theSshow - I was suggestion if you couldn't make the boolean property Boolean (to support a null value), then you could create an AdaptedEmployee class (it should not extend Employee to use with the XmlAdapter (see - objects.html).. details
    • If you don't use JAXB annotated objects, but simple POJO's, you can get the correct behaviour by simply enabling the POJO mapping feature, together with the Jackson JSON library.. details
    • We're working on improving our Maven setup.. details
    • Put some assertions to check not null** objects and list not empty**.. details
    • So far I have been creating inner classes to support the wrapper, though I don't like the plumbing as it were as I then need to do it for every pojo.. details
    • I tried making a generic class like XmlList<T> and create new instances on return but JAXB appears to not like this.. details
    • 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.. details
    • The above should get you started... Also, you would need to mark each subclass like so: CODESNIPPET .. details
    • You can define custom serializer (and deserializer if you need it back) using @JsonSerialize(contentUsing=MySerializer.class); (contentUsing because it's to be used for List values, not List itself).. details
    • Both fields had null values.. details
    • You can use Object to Xml converter like JAXB to make your life easier.. details
    • I cant seem to post JSON to my webservice but XML works fine: CODESNIPPET .. details
    • Just make sure your pojos are annotated correctly.. details
    • Here is a simple pojo CODESNIPPET .. details
    • You got it, but works if I leave XML beans out.. details
    • So I launch a simple request to Twitter : CODESNIPPET .. details
    • Perhaps its support was not enabled: .. details
  • 9. response jax case produce double schema quote simple key generate: 16
    • Thanks a a lot for your help.. details
    • Thanks for the full example, its awesome!!. details
    • If this is what your environment is doing the using JAXBElement is the correct thing to do.. details
    • Thanks a lot,that really helps.. details
    • Because of the XML (as I want the same behaviour for XML as well) there is necessity to use @XmlEnumValue etc.. details
    • Please note that on processRequest() I'm currently producing a text response, but that will be changed later to produce a JSON.. details
    • My response object is simple and uses normal annotations: CODESNIPPET .. details
    • If the value is coming as 1234AS in this case returns with double quote.How to fix this and making sure its always has double quotes.. details
    • The net effect is that rather than writing lots of little getJSONObject() calls, you invest in setting up corresponding classes, this should result in nicely structured code, where the processing of the data, that is the real business logic, is separated from the parsing code, which I view as "plumbing".. details
    • Blaise, thanks for your answer!. details
    • We make the value of these keys JSON arrays since keys are not allowed to repeat.. details
    • Demo Below is some standalone code to demonstrate the reading/writing of the JSON.. details
    • and the relevant resource signature looks like this: CODESNIPPET .. details
    • The Xml is fine, the json is nearly fine except that because Json directly supports arrays having elements like ipi-list and artist-list doesnt seem very json, is it possible to generate more json like json from my model ?. details
    • Thanks for the link, Blaise.. details
    • edit: I asked my question another way to try to make it clear: to-a-different-schema-with-jax-rs [how-to-map-a-bean-structure-to-a-different- schema-with-jax-rs] .. details
  • 0. jaxb setter add model eclipselink subclass fetch getter provider define: 14
    • Problems with Your Model There are a few problems with your model: Getter with no Setter** By default JAXB Will not consider a get method without a corresponding set method as a property.. details
    • The actual model is a little more complex then Ive posted but the additional elements dont seem relevant to the issue.. details
    • It's a shame that JAXB can't see the setter if it's defined in the super class.. details
    • When you want the shallow fetch, use the default fetch plan and make your returned object transient, e.g.. details
    • For More Information** QUESTION 2 Second, is there a way to get rid of "bird", "cat", and "dog"?. details
    • Key By specifying @XmlPath(".") the contents of the reference object are pulled up into the node corresponding to the source object.. details
    • This best mechanisms for this are: EclipseLink Forum: EclipseLink Users Mailing List: eclipselink-users AT eclipse.org** Enter a Bug: For More Information** UPDATE Thanks for the answer although I'm not convinced requiring me to add element to prop order just because I want to rename it is an improvement.. details
    • Do I dispense with all the custom mapping information and just use JAXB or Spring OXM?. details
    • Adding layers between the two (such as manually handling data binding) can help but is more work.This is not unique to JSON (XML data binding with libs like JAXB has similar challenges), or even data formats: Hibernate and other ORM libs can also add more close-coupling.Another potential challenge is that of losing visibility into what is happening: data binding is often a black box, and when things work, that's great (fewer things to worry about), but when they don't trouble-shooting may be more difficult.. details
    • It should work as you show; with one possible exception: if you enable JAXB annotations (only), JAXB restrictions mandate that only getter/setter pairs are used to detect properties.So try adding setter for 'biz' and see if that changes it.. details
    • If I make my Wrapper class have its "result" field defined as subclass type "SubClass" it works OK, but when it is of type "SuperClass" but the instance of of SubClass I get the error.. details
    • Problem is: an "issue" has a "summary" property and a list of fields.. details
    • I can fetch the Download object itself without any problems... CODESNIPPET .. details
    • Output of project.json (see nested technologies list): CODESNIPPET .. details
  • 1. solve jaxb marshal add html instance weapon binding produce myfoocollectionwrapper: 10
    • @StaxMan his issue is that he wants to force the parsing of JSON into complex objects and he is having issues.. details
    • Ok, I'm a little embarrassed - adding the dependency does fix the problem and I don't know why I didn't test it before!. details
    • What can I do to solve my problem?. details
    • The setAnnotationIntrospector is deprecated, is there any other way of solving this problem?. details
    • MapAdapter An XmlAdapter allows you to marshal an instance of one class as an instance of another class (see: secret-weapon.html [ - weapon.html] ).. details
    • As a side note, if I add JAXB annotations to my entities (@XmlRootElement on MyFooCollectionWrapper and MyFooDTO) the using the same webResource get call, the client I do not get a message body reader exception, however, the response is marshaled such that MyFooCollectionWrapper looks ok but its collection does not contain a MyFooDTO it contains an XML Document with the proper values in the nodes/attrs - in other words MyFooDTP doesn't get marshaled.. details
    • Doh - sorry, when making the example - I messed up the code trying to make it simpler (should have been setBiz).. details
    • Someone suggested a way to solve my problem (in -different-schema-with-jax-rs), although it requires using Eclipselink Moxy, which I don't want to introduce (additional dependency and jaxb replacement in whole application).. details
    • Setting the Download object to be a JAXB annotated class should solve the problem.. details
    • Works nicely with Jersey, and I am use it myself (current Jersey version does not bundle full Pojo data binding by default, but will in near future) I would actually not use any of xml libs to produce "json": XStream and JAXB/Jettison can produce kind of JSON, but it uses ugly conventions that are rather non-intuitive.. details
  • 2. jaxb follow team exception implementation jackson moxy call read mapping: 13
    • JAXB cant handle non-static inner classes.. details
    • But when I try to convert the JSON back into the JAXB object, it throws an exception connected somehow with the JAXBElement.. details
    • BTW, if it wasn't clear, the annotations above are standard JAXB which JAX-RS implementations should follow.. details
    • MOXy uses the same XJC code as the reference implementation and the JAXB RI also throws an exception if the propOrder is incomplete so I'm not sure what scenario would have excluded it.. details
    • For More Information** I noticed that you had the following comment in your code: // getters and setters with @XmlElement on each attribute Because JAXB (JSR-222) implementations are configuration by exception, you only need to add annotations where you want the XML representation from the default.. details
    • Our use case was more complex with DTOs, JPA entities, versioning etc.. details
    • I'm re-asking an unanswered question from the now read-only google groups App Engine for Java because I have the exact same problem.. details
    • I get the following error with JSON: CODESNIPPET .. details
    • Ok, no solution found with Jettison (I'm convinced it's a bug) and JAXB mapping for JSON.. details
    • I assume it comes from a wrong JAXB mapping on SearchResults class but can't figure how to correct it (and it's complicated with the JSON translation to XML).. details
    • But I'm struggling to understand how to make an employeea member of a team at creation-time by just passing in a Team ID, ratherthan passing in a nested team object in my JSON object.. details
    • Ok, i just figured your case was more complex than i though.... details
    • EDIT (18-Jul-2011): Jackson actually has an extension called " jackson-xml-databind " that can read/write XML, similar to JAXB.. details
  • 3. jaxb moxy html exception provider model eclipselink property trunk jinahya: 20
    • There also must be a way of doing this using PropertyNamingStrategy, the problem I am facing with it is that Spring MVC is handling it somehow differently than serializing something directly with ObjectMapper from JAXB objects.. details
    • It was a problem with jaxb.. details
    • The exception being thrown is an RI exception (com.sun.xml.internal.bind.v2.runtime package) so EclipseLink MOXy is not being picked up as the JAXB provider.. details
    • Thanks for quick response I am facing javax.xml.bind.JAXBException: property "eclipselink.media-type" is not supported exception.. details
    • Here is a complete example of how this can be done with EclipseLink JAXB (MOXy): - moxy.html.. details
    • Solution to Both Problems Instead of using the default property access, you can use the @XmlAccessorType annotation to tell JAXB to use field access.. details
    • I'm using JAXB 2.2.5 rather than MOXy for class generation, the full source code for schema generation is available from - schema/trunk/brainz-mmd2-jaxb/ (note the last checkin of DiscList contains a manually modified propOrder, my fix before I saw yours).. details
    • 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 (see: your.html [ - your.html] ): CODESNIPPET .. details
    • JAXB (JSR-222) is configuration by exception and only requires annotations where you need to override the default XML representation (Jettison converts XML StAX events to/from JSON).. details
    • 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 (see: your.html [ - your.html] ): CODESNIPPET .. details
    • DEMO CODE** _**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 (see: your.html [ - your.html] ): CODESNIPPET .. details
    • Problem was in the xjb file, for details look in the related question here .. details
    • You can see full mavenized project at rce/browse/trunk/com.googlecode.jinahya/stackoverflow/ [ /p/jinahya/source/browse/trunk/com.googlecode.jinahya/stackoverflow/ JAXB doesn't need the setter if you control to use fields not properties.. details
    • jaxb.properties To specify MOXy as your JAXB provider you need to include a file called jaxb.properties with the followin entry (see /specifying-eclipselink-moxy-as-your.html [ /specifying-eclipselink-moxy-as-your.html ): CODESNIPPET .. details
    • By default EclipseLink- JAXB-(MOXy)] will marshal the JSON to one line.. details
    • 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 (see ): CODESNIPPET .. details
    • Or do the more common trick of just using a string and don't worry about trying to magically hook everything up in the binding layer.. details
    • and class that represents "gadget" model (annotated with @XmlRootElement for JAXB processing): CODESNIPPET .. details
    • When I do it, I get error: java.lang.IllegalStateException: Invalid JSON namespace: /XMLSchema-instance Specifically, I have a "Wrapper" class with a "result" field of type SuperClass but it will always be an instance of some sub class ("SubClass" below).. details
    • For best compatibility 1.6.1 has some further improvements to reduce warnings during initialization (used to complain about missing javax.xml and Joda classes, not any more) .. details
  • 4. moxy binding provider jersey follow glassfish include model complete edit: 8
    • For More Information** MOXy as the Default JSON-Binding Provider in Jersey/GlassFish If you are using MOXy as the default JSON-binding provider with Jersey/GlassFish you can leverage the MoxyJsonConfig class as follows: CODESNIPPET .. details
    • By default MOXyJsonProvider is configured not to include the root element.. details
    • EDIT**:This is what Fiddler captures when I post the JSON data: CODESNIPPET .. details
    • I am getting the following Exception when I try to marshall the java object to Json CODESNIPPET .. details
    • I would like to see if there is an actual bug here.. details
    • So essentially I want to merge all the relations so they are in one list and lose the relationlist label.. details
    • +1 Ahh...I see you beat me to the punch.. details
    • However, this always bothered me because it throughly ties your interface and messages with the structure and design of your data model.. details
  • 5. jaxb jackson force add model follow implementation reply schema bracket: 20
    • There is also possibility that JAXB annotation introspector extension (it's a Jackson add-on) could have a bug here.. details
    • I'm attempting to follow the example located vice-versa-using-jackson-api-and-jaxb-annotation [here] but get an javax.xml.bind.PropertyException.. details
    • You can't blame me or my answer for the existence of a disagreement between jaxb and jackson.. details
    • Is there a way to map JAXB Objects into JSON with some other means, but which will follow the whole JAXB specification so that I have no problems in the future converting from JSON to the JAXB object and visa vera?. details
    • So i then edited Alias.java to add beginDate to propOrder, but this gave this error.. details
    • Mapper transfers it logically to: The JAXB specification** itself does not cover JSON-binding so sometimes implementations are used with libraries like Jettison which converts XML events to/from JSON and problems occur such as collections of size 1 being represented incorrectly.. details
    • Thanks for this very detailed reply, sorry I should have replied earlier but havent quite understood if it will do what I want.. details
    • Converting JSON to XML and vice versa using Jackson API and JAXB Annotation.. details
    • I suspect this has something to do with the fact that XmlAdapter is a list rather than a single value.. details
    • FWIW, this way (of applying to elements) was heavily influenced by JAXB, which has this behavior.. details
    • (At the bottom you can find the error message, the WS, the objects & the xsd for one example) Thanks in advance.. details
    • Maybe the stack trace holds the solution Update The full project is available online The data model is at mmd2-jaxb/ [ Download and run mvn install Then the project that uses this is at Download and run mvn package, This contains three subprojects and the problem one is the servlet project, to replicate the issue: cd servlet Edit src/main/resources/oxml.xml changing CODESNIPPET .. details
    • _**One Line**_ By default when you include MOXyJsonProvider in your JAX-RS application, the output will be marshalled on one line: CODESNIPPET .. details
    • JAXB implementations have default rules for mapping field/property names, but since your document differs from the default each field had to be annotated.. details
    • Additional Information as Requested**The json is generated from this MMD schema using JAXB and Jersey , see and The point is that I want to be able to generate Json and XML from one schema with the minimum of fuss, but apparently the Json doesn't look right so Im looking for a way to improve it (I don't really have any experience of json myself) .. details
    • I've tried out Jackson but the problem is that its a major rewrite for us since we're so dependent on our JAXB annotations.. details
    • JAXB JSON force brackets on arrays.. details
    • I'm trying to force brackets on lists that contain only one element.. details
    • This may cause data loss because of differences in data model between XML and JSON.. details
    • Since I am more familiar with Jackson, here are some aspects where I think Jackson has more complete support than Gson (apologies if I miss a Gson feature): Extensive annotation support; including full inheritance, and advanced "mix-in" annotations (associate annotations with a class for cases where you can not directly add them) Streaming (incremental) reading, writing, for ultra-high performance (or memory-limited) use cases; can mix with data binding (bind sub-trees) -- EDIT latest versions of Gson also include streaming reader Tree model (DOM-like access); can convert between various models (tree <-> java object <-> stream) Can use any constructors (or static factory methods), not just default constructor Field and getter/setter access (earlier gson versions only used fields, this may have changed) Out-of-box JAX-RS support Interoperability: can also use JAXB annotations, has support/work-arounds for common packages (joda, ibatis, cglib), JVM languages (groovy, clojure, scala) Ability to force static (declared) type handling for output Support for deserializing polymorphic types (Jackson 1.5) -- can serialize AND deserialize things like List correctly (with additional type information) Integrated support for binary content (base64 to/from JSON Strings) .. details
  • 6. jaxb provider moxy jersey jax eclipselink relationlist mapping update jackson: 30
    • My classes have jaxb annotations and the system application provider seems to interfere with the jackson json provider.. details
    • What's the problem?. details
    • I think I ended up tracing through it and found that it was a problem in the json provider.. details
    • The problem was the we left the old JAXB provider hanging around with it's @Provider annotation.. details
    • Have to go, sorry.. details
    • For More Information** .. details
    • For More Information** .. details
    • but that is not what I want Update with attempt to use Denises answer** I've ran into a few problems with the proposed solution, first here is the full Alias class I think that would help (note the classes autogenned with JAXB, I came across this before ElipseLink and because my Xml output is okay Im not particulary keen to change this) CODESNIPPET .. details
    • Oh I see, the problem is you can have more than one relation-list element (with a different type attribute), so instead of there being a RelationList element, there isd a list of RelationList elements /mmd-schema/trunk/brainz- mmd2-jaxb/src/main/java/org/musicbrainz/mmd2/Work.java right well least I can see the problem now.. details
    • Unfortunately it doesn't work.. details
    • error.. details
    • But I think, that it's wrong, when object converts to String.. details
    • JAXB is for XML, are you confusing it with JAX-RS?. details
    • The error: CODESNIPPET .. details
    • I think there's some type confusion in getJAXBContext().. details
    • Related Bug** Recommended Fix** If you add a new mapping in the external mapping file (which is a bit rare since you would have had to explicitly remove the mapping via annotations - ).. details
    • The default Jersey Jackson provider is configured to use JAXB annotations alongside Jackson ones ;-) The only issue is that the exact configuration of this provider is not documented :-(.. details
    • mvn package src/test/java/org/musicbrainz/search/servlet/FindWorkTest will now fail ontestOutputAsJsonNew() and testOutputAsJsonNewPretty() Further Update**Blaise worked out the problem the example doesn't show (and I wasn't aware) that you can actually have multiple relationList elements, i.e the Xml could be CODESNIPPET .. details
    • Many libraries incorrectly treat collections of size 1 as JSON objects.. details
    • To solve another problem I have moved from using Jersey to EclipseLink MOXy to generate JSON from a JAXB created object model ( created by Sun JAXB 2.1.12).. details
    • You can use a Provider to change default behaviour of JSONJAXBContext.. details
    • For More Information** MOXy-as-Your-JAX-RS-JSON-Provider---Client-Side MOXy-as-Your-JAX-RS-JSON-Provider---Server-Side Specifying-EclipseLink-MOXy-as-Your-JAXB-Provider UPDATE In GlassFish 4 EclipseLink JAXB (MOXy) is the default JSON-binding provider used by Jersey: .. details
    • I have an XSD file with enumeration in lower case e.g.. details
    • The problem I had with this is, that the types you give to the JSONJAXBContext need to have a no-arg constructor.. details
    • What's wrong?. details
    • Do you guys have any idea what the problem might be?. details
    • it's really frustrating and I've been fighting with this issue for almost 5 hours now... :( I'd expect JAXB/Jersey to embed my list of downloads in the Project's Json Feed... but unfortunately it's completely missing.. details
    • Is there a better way to decouple these without subjecting yourself to tedious translation/conversion classes?. details
    • What am doing wrong here?. details
    • Sorry this is such a sketchy question, but as I say, I'm just startingout, and terminology is a problem for me at this stage!. details
  • 7. jaxb jersey jackson moxy eclipselink html provider jettison request add: 16
    • Yeah., But sometimes I may need to marshall objects which has @Entity annotation too., In that case it will conflict if I try to wrap it in JAXBElement.. details
    • If the above plugin doesn't do exactly what you want (which I think it should, it looks pretty flexible), it shouldn't be too difficult to roll your own modification (I have done this before for adding copy constructors to generated classes).. details
    • The key names in JSON will differ on the basis of annotation provided.. details
    • BTW String is also an Object so your Android client (about which you should give some info if that is the problem) should work.. details
    • There do appear to be Eclipse-tools that automate this manual drudgery.. details
    • Json Response String is {"0":{"0":"Rockey","1":"John"}} I am using Apache CXF Framework with Jettison as the JSON Provider also uses JAXB to wire the data to low bandwidth clients.. details
    • The phone-number element is a complex type with simple content (see: ).. details
    • I followed the instructions example-with-jersey-jackson/ [here] which show how to use Jersey and Jackson POJOs(as opposed to JAXB).. details
    • By default, Jersey is using JAXB for the (un)marshalling process, and unfortunately, JAXB JSON processor is not standard (_one-element arrays are ignored, empty arrays are transformed into a one-element empty array..._).. details
    • This would not occur with Jackson annotations; and ideally not if you combine Jackson and JAXB annotations (I thought Jersey enabled both).If Jackson annotation processing is also enabled, adding @JsonProperty next to 'getBiz' should also do the trick.. details
    • By default Jersey will use JAXB to process the JSON messages by leveraging the Jettison library.. details
    • You can leverage the @XmlPath extension in EclipseLink JAXB (MOXy) to break the relationship between then entity model and the message format (I'm the MOXy tech lead): JAXB2:-Mapping-nested-elements-into-the-same-Java-class .. details
    • At low level, what is needed to make sure that ObjectMapper does NOT use JAXBAnnotationIntrospector, but only default JacksonAnnotationIntrospector.. details
    • I'm a bit new to use JSON format manipulation and not very experimented in JAXB either.What I try to do is building a small client to launch search on Twitter.. details
    • Default setting is false, meaning root value is not wrapped.. details
    • The problem is that when I am trying to use the same for un-marshalling my request it doesnt work.. details
  • 8. jaxb null provider html approach case jax implementation car xmlelement: 14
    • +1 - Also since JAXB is the default binding layer for JAX-RS you can just return a JAXB model class and the JAX-RS implementation will leverage JAXB to convert it to XML: - service-part-35.html.. details
    • You could do the following with @XmlElementWrapper (see: ): CODESNIPPET .. details
    • Can't you tell me, what's wrong with that approach?. details
    • As seen here, the 'element' tag is lost in the json.. details
    • Unfortunately I cannot use the @XmlElement option because beginDate is an attribute not an element and already has a @XmlAttribute annotation, and this does not seem to support nillable.. details
    • If you are using the n.html#json.jaxb.approach.section [JAXB] approach, you can mark fields with @XmlTransient to omit them.. details
    • FYI WebLogic switched to MOXy as the default JAXB provider: - provider-in.html.. details
    • Actually I don't think his problem is really that: if you look carefully at JSON sample he is showing, the multi-object case, there is the bigger issue of content being a String, not JSON.. details
    • One that we can use internally and one that we will expose externally.. details
    • In my example I'm using MOXy's default reprentation of Timestamp .. details
    • But the actual requirement is a more complex transformation, Im not sure how to explain it in the correct terminology but here is an example of the required output.. details
    • Below is an example of how the @XmlElement annotation can be leveraged to map your use case: Foo By default a JAXB implementation will not marshal a null property.. details
    • But unfortunately in the latest version of the api they have dropped xml support and only return json.. details
    • So we find a painful way of checking each field in the car object and if they are null, then set the car as null, so jackson jaxb provider can render it as null.. details
  • 9. jersey exception find jaxb util follow message additional add response: 7
    • The problem is that most of what I found is for webapps, in which the part of the configuration which I need is under the hood.. details
    • Could be but I think here the problem is ahead, I am not hitting the service at all.. details
    • I'm concerned that the manner in which i annotate the getter method might be affecting the overall bean as it's passed to the server?. details
    • It works _almost_ fine, however the _first_ request to the server always ends up with the exception: java.lang.NoClassDefFoundError: org/codehaus/jackson/xc/JaxbAnnotationIntrospector For some reason gae/jersey cannot find this class on the initial request.. details
    • I found JAXB is too "fat" for my needs.. details
    • But for JSON I get the following exception: SEVERE: Mapped exception to response: 500 (Internal Server Error) javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: A message body writer for Java class java.util.Arrays$ArrayList, and Java type java.util.List, and MIME media type application/json was not found I use Jersey 1.6 and, according to the tutorial, JSON format should work with JAXB without any additional programming.. details
    • On the other hand, if you're using the Jersey JSON plugin, you'd have to write a subclass of Map , and add JAXB annotations to it - kind of a pain in the ass.. details
Summaries of the opinions about javax.xml using three algorithms (Textrank, Lexrank and Luhn) adopted from extractive summarization. Each algorithm was used once for the positive opinions and once for the negative opinions.
  • Below is how you an support your use case with your Student class as annotated with EclipseLink JAXB (MOXy) .
  • I would recommend using Jackson as it is superior to other recommended alternatives when producing JSON, and for XML either: Use a JAXB implementation with JAXB annotations (Jackson can optionally support JAXB annotations as well, so very little overhead of 2 libs) Use Jackson xml databind module to produce XML using Jackson itself (in format that is usually identical to JAXB produced) I do NOT think that you absolute must use a single library or framework, and the result is often better if you just choose best choice for each separately .
  • I was struggling with this as well, but this question is similar and the answer works java class to a json using jaxb Binding a Generic Java Class to a JSON using JAXB It's a fairly simple answer although I'd struggle to explain why or how it works and doesn't cause the mapping to occur .
  • Thanks for that but I would prefer to not use any plugs in, I know there is a simple way that I could do it with a simple for each object in the array loop I had it going before but I cant find it again .
  • If you are ultimately looking for a way to interact with JSON using a JAXB (JSR 222) implementation, then the following is how it can be done using MOXy .
  • So to model it, you need something like this: CODESNIPPET JAVA1 .
  • Thanks to serialization of a list of jaxb objects to json 3143214#3143214 How can I customize serialization of a list of JAXB objects to JSON?.
  • i have a class like : CODESNIPPET JAVA1 .
  • Looks like you are making use of JAXB for XML and Jackson for JSON .
  • I want it to be like, CODESNIPPET JAVA4 .
  • The simplest way of doing this is to use JAXB to create the tooled version of the structure (with something like Jackson as the serialization engine) and then to create a factory method somewhere that will make the structure for you without you having to specify anything extra yourself .
  • I tried it and the XML consisted of one empty tag only, meaning there's something about the POJO model that JAXB doesn't like .
  • That's interesting because it seems to indicate that the only part JAXB plays in this is to lend its annotations and some other interfaces (e g .
  • I tried it and the XML consisted of one empty tag only, meaning there's something about the POJO model that JAXB doesn't like .
  • That's interesting because it seems to indicate that the only part JAXB plays in this is to lend its annotations and some other interfaces (e g .
  • POJO to XML** JAXB is the Java standard ( JSR 222 ) for converting Java objects to from XML (I am a member of the JAXB expert group): POJO to JSON** People have been using JAXB with Jettison to produce JSON .
  • I would recommend using Jackson as it is superior to other recommended alternatives when producing JSON, and for XML either: Use a JAXB implementation with JAXB annotations (Jackson can optionally support JAXB annotations as well, so very little overhead of 2 libs) Use Jackson xml databind module to produce XML using Jackson itself (in format that is usually identical to JAXB produced) I do NOT think that you absolute must use a single library or framework, and the result is often better if you just choose best choice for each separately .
  • I was struggling with this as well, but this question is similar and the answer works java class to a json using jaxb Binding a Generic Java Class to a JSON using JAXB It's a fairly simple answer although I'd struggle to explain why or how it works and doesn't cause the mapping to occur .
  • Given a model object Foo create a JsonFoo and XmlFoo 2) Write a custom message converter I tried this and it turned out to be a bit complicated since the view must know how to resolve e g , a Foo to a JsonFoo to be able to serialize it into a readable format .
  • I would like to use JAXB in a JavaSE standalone application to read and write Json files I managed to do it for XML files with my snippet below, but I don't understand how to switch to Json: CODESNIPPET JAVA1 .
  • So, can I do something like: @GET @Path(" userinfo {id}") @Produces({"application xml", "application json"}) public String getUserInfo(@PathParam("id") String id) {String users null;User user null;user new UserManager() getUserInfo(id); JAXBContext jaxbContext JAXBContext newInstance(User class);Marshaller jaxbMarshaller jaxbContext createMarshaller(); jaxbMarshaller setProperty(Marshaller JAXB FORMATTED OUTPUT, true);jaxbMarshaller marshal(user, System out); users jaxbMarshaller toString(); return users;} .
  • The simplest way of doing this is to use JAXB to create the tooled version of the structure (with something like Jackson as the serialization engine) and then to create a factory method somewhere that will make the structure for you without you having to specify anything extra yourself .
  • Thanks for the answer, in this third solution, the example code which is used isColumnPositionMappingStrategy strat new ColumnPositionMappingStrategy();strat setType(YourOrderBean class);String[ columns new String[ {"name", "orderNumber", "id"}; the fields to bind do in your JavaBeanstrat setColumnMapping(columns);CsvToBean csv new CsvToBean();List list csv parse(strat, yourReader);what exactly is yourReader here, and how do I input values to bind with bean?.
  • My starting framework is JBoss RESTEasy (JAX RS implementation) that provides an elegant way to consume Rest services JSON services by mapping JSON to JAXB thru Jettison framework (it works also in the other way if you want to provide REST service and produce JSON from JAXB) .
  • If you update Jackson to 2 0 it is not deprecated: databind javadoc 2 0 0 com fasterxml jackson databind ObjectMapper html databind javadoc 2 0 0 com fasterxml jackson databind ObjectMapper html You can see my configuration here (Spring): mappingjackson2httpmessageconverter in spring 3 1 2 with jaxb annotati Registrer MappingJackson2HttpMessageConverter in Spring 3 1 2 with JAXB annotations .
  • I would recommend using Jackson as it is superior to other recommended alternatives when producing JSON, and for XML either: Use a JAXB implementation with JAXB annotations (Jackson can optionally support JAXB annotations as well, so very little overhead of 2 libs) Use Jackson xml databind module to produce XML using Jackson itself (in format that is usually identical to JAXB produced) I do NOT think that you absolute must use a single library or framework, and the result is often better if you just choose best choice for each separately .
  • I was struggling with this as well, but this question is similar and the answer works java class to a json using jaxb Binding a Generic Java Class to a JSON using JAXB It's a fairly simple answer although I'd struggle to explain why or how it works and doesn't cause the mapping to occur .
  • Thanks for that but I would prefer to not use any plugs in, I know there is a simple way that I could do it with a simple for each object in the array loop I had it going before but I cant find it again .
  • Given a model object Foo create a JsonFoo and XmlFoo 2) Write a custom message converter I tried this and it turned out to be a bit complicated since the view must know how to resolve e g , a Foo to a JsonFoo to be able to serialize it into a readable format .
  • EDIT: I now found this setting: USE GETTERS AS SETTERS (default: true) Controls whether "getters" that return Collection or Map types can be used for "setting" values (same as how JAXB API works with XML), so that separate "setter" method is not needed .
  • Is there a way to map JAXB Objects into JSON with some other means, but which will follow the whole JAXB specification so that I have no problems in the future converting from JSON to the JAXB object and visa vera?.
  • What can I do to solve my problem?.
  • It should work as you show; with one possible exception: if you enable JAXB annotations (only), JAXB restrictions mandate that only getter setter pairs are used to detect properties So try adding setter for 'biz' and see if that changes it .
  • Oh I see, the problem is you can have more than one relation list element (with a different type attribute), so instead of there being a RelationList element, there isd a list of RelationList elements mmd schema trunk brainz mmd2 jaxb src main java org musicbrainz mmd2 Work java right well least I can see the problem now .
  • For More Information** MOXy as the Default JSON Binding Provider in Jersey GlassFish If you are using MOXy as the default JSON binding provider with Jersey GlassFish you can leverage the MoxyJsonConfig class as follows: CODESNIPPET JAVA3 .
  • It was a problem with jaxb .
  • What's the problem?.
  • For More Information** MOXy as Your JAX RS JSON Provider Client Side MOXy as Your JAX RS JSON Provider Server Side Specifying EclipseLink MOXy as Your JAXB Provider UPDATE In GlassFish 4 EclipseLink JAXB (MOXy) is the default JSON binding provider used by Jersey: .
  • The default Jersey Jackson provider is configured to use JAXB annotations alongside Jackson ones ; ) The only issue is that the exact configuration of this provider is not documented : ( .
  • Below is an example of how the @XmlElement annotation can be leveraged to map your use case: Foo By default a JAXB implementation will not marshal a null property .
  • Since I am more familiar with Jackson, here are some aspects where I think Jackson has more complete support than Gson (apologies if I miss a Gson feature): Extensive annotation support; including full inheritance, and advanced "mix in" annotations (associate annotations with a class for cases where you can not directly add them) Streaming (incremental) reading, writing, for ultra high performance (or memory limited) use cases; can mix with data binding (bind sub trees) EDIT latest versions of Gson also include streaming reader Tree model (DOM like access); can convert between various models (tree < > java object < > stream) Can use any constructors (or static factory methods), not just default constructor Field and getter setter access (earlier gson versions only used fields, this may have changed) Out of box JAX RS support Interoperability: can also use JAXB annotations, has support work arounds for common packages (joda, ibatis, cglib), JVM languages (groovy, clojure, scala) Ability to force static (declared) type handling for output Support for deserializing polymorphic types (Jackson 1 5) can serialize AND deserialize things like List correctly (with additional type information) Integrated support for binary content (base64 to from JSON Strings) .
  • Is there a way to map JAXB Objects into JSON with some other means, but which will follow the whole JAXB specification so that I have no problems in the future converting from JSON to the JAXB object and visa vera?.
  • You can leverage the @XmlPath extension in EclipseLink JAXB (MOXy) to break the relationship between then entity model and the message format (I'm the MOXy tech lead): JAXB2: Mapping nested elements into the same Java class .
  • but that is not what I want Update with attempt to use Denises answer** I've ran into a few problems with the proposed solution, first here is the full Alias class I think that would help (note the classes autogenned with JAXB, I came across this before ElipseLink and because my Xml output is okay Im not particulary keen to change this) CODESNIPPET JAVA4 .
  • But for JSON I get the following exception: SEVERE: Mapped exception to response: 500 (Internal Server Error) javax ws rs WebApplicationException: com sun jersey api MessageException: A message body writer for Java class java util Arrays$ArrayList, and Java type java util List, and MIME media type application json was not found I use Jersey 1 6 and, according to the tutorial, JSON format should work with JAXB without any additional programming .
  • Maybe the stack trace holds the solution Update The full project is available online The data model is at mmd2 jaxb Download and run mvn install Then the project that uses this is at Download and run mvn package, This contains three subprojects and the problem one is the servlet project, to replicate the issue: cd servlet Edit src main resources oxml xml changing CODESNIPPET JAVA8 .
  • On the other hand, if you're using the Jersey JSON plugin, you'd have to write a subclass of Map , and add JAXB annotations to it kind of a pain in the ass .
  • Additional Information as Requested**The json is generated from this MMD schema using JAXB and Jersey , see and The point is that I want to be able to generate Json and XML from one schema with the minimum of fuss, but apparently the Json doesn't look right so Im looking for a way to improve it (I don't really have any experience of json myself) .
  • As a side note, if I add JAXB annotations to my entities (@XmlRootElement on MyFooCollectionWrapper and MyFooDTO) the using the same webResource get call, the client I do not get a message body reader exception, however, the response is marshaled such that MyFooCollectionWrapper looks ok but its collection does not contain a MyFooDTO it contains an XML Document with the proper values in the nodes attrs in other words MyFooDTP doesn't get marshaled .
  • Adding layers between the two (such as manually handling data binding) can help but is more work This is not unique to JSON (XML data binding with libs like JAXB has similar challenges), or even data formats: Hibernate and other ORM libs can also add more close coupling Another potential challenge is that of losing visibility into what is happening: data binding is often a black box, and when things work, that's great (fewer things to worry about), but when they don't trouble shooting may be more difficult .
  • Since I am more familiar with Jackson, here are some aspects where I think Jackson has more complete support than Gson (apologies if I miss a Gson feature): Extensive annotation support; including full inheritance, and advanced "mix in" annotations (associate annotations with a class for cases where you can not directly add them) Streaming (incremental) reading, writing, for ultra high performance (or memory limited) use cases; can mix with data binding (bind sub trees) EDIT latest versions of Gson also include streaming reader Tree model (DOM like access); can convert between various models (tree < > java object < > stream) Can use any constructors (or static factory methods), not just default constructor Field and getter setter access (earlier gson versions only used fields, this may have changed) Out of box JAX RS support Interoperability: can also use JAXB annotations, has support work arounds for common packages (joda, ibatis, cglib), JVM languages (groovy, clojure, scala) Ability to force static (declared) type handling for output Support for deserializing polymorphic types (Jackson 1 5) can serialize AND deserialize things like List correctly (with additional type information) Integrated support for binary content (base64 to from JSON Strings) .
  • but that is not what I want Update with attempt to use Denises answer** I've ran into a few problems with the proposed solution, first here is the full Alias class I think that would help (note the classes autogenned with JAXB, I came across this before ElipseLink and because my Xml output is okay Im not particulary keen to change this) CODESNIPPET JAVA4 .
  • But for JSON I get the following exception: SEVERE: Mapped exception to response: 500 (Internal Server Error) javax ws rs WebApplicationException: com sun jersey api MessageException: A message body writer for Java class java util Arrays$ArrayList, and Java type java util List, and MIME media type application json was not found I use Jersey 1 6 and, according to the tutorial, JSON format should work with JAXB without any additional programming .
  • Maybe the stack trace holds the solution Update The full project is available online The data model is at mmd2 jaxb Download and run mvn install Then the project that uses this is at Download and run mvn package, This contains three subprojects and the problem one is the servlet project, to replicate the issue: cd servlet Edit src main resources oxml xml changing CODESNIPPET JAVA8 .
  • Oh I see, the problem is you can have more than one relation list element (with a different type attribute), so instead of there being a RelationList element, there isd a list of RelationList elements mmd schema trunk brainz mmd2 jaxb src main java org musicbrainz mmd2 Work java right well least I can see the problem now .
  • Additional Information as Requested**The json is generated from this MMD schema using JAXB and Jersey , see and The point is that I want to be able to generate Json and XML from one schema with the minimum of fuss, but apparently the Json doesn't look right so Im looking for a way to improve it (I don't really have any experience of json myself) .
  • As a side note, if I add JAXB annotations to my entities (@XmlRootElement on MyFooCollectionWrapper and MyFooDTO) the using the same webResource get call, the client I do not get a message body reader exception, however, the response is marshaled such that MyFooCollectionWrapper looks ok but its collection does not contain a MyFooDTO it contains an XML Document with the proper values in the nodes attrs in other words MyFooDTP doesn't get marshaled .
  • Adding layers between the two (such as manually handling data binding) can help but is more work This is not unique to JSON (XML data binding with libs like JAXB has similar challenges), or even data formats: Hibernate and other ORM libs can also add more close coupling Another potential challenge is that of losing visibility into what is happening: data binding is often a black box, and when things work, that's great (fewer things to worry about), but when they don't trouble shooting may be more difficult .
  • Works nicely with Jersey, and I am use it myself (current Jersey version does not bundle full Pojo data binding by default, but will in near future) I would actually not use any of xml libs to produce "json": XStream and JAXB Jettison can produce kind of JSON, but it uses ugly conventions that are rather non intuitive .
  • For More Information** MOXy as Your JAX RS JSON Provider Client Side MOXy as Your JAX RS JSON Provider Server Side Specifying EclipseLink MOXy as Your JAXB Provider UPDATE In GlassFish 4 EclipseLink JAXB (MOXy) is the default JSON binding provider used by Jersey: .
Summaries of the opinions about javax.xml using Opinosis, an abstractive summarizer of opinions..
  • eclipselink jaxb (/( moxy )/) offers native json .
  • the jaxb plays in this to lend its annotations and some other interfaces (/( e g .
  • empty tag only , there 's something about the pojo model that jaxb does n't like and .
  • demo below is a standalone example you can run to prove everything works .
  • good reuse of jaxb annotations and jaxb .
  • null value .
  • standard jaxb apis are used .
  • native support .
  • everything is fine .
  • due to jaxb .
  • file called jaxb.properties in the same package as your domain model with the (/( see :/: and your model with the (/( see :/: .
Summaries of the opinions about javax.xml using contrastive viewpoints. Each entry contains a pair of positive and negative sentences that are most likely discussing about similar API features.
    • Update: JAXB annotation are great for interop with XML system, but you should really use Jackson's own annotation if you can .
    • My classes have jaxb annotations and the system application provider seems to interfere with the jackson json provider .
    • This would be useful as I do not believe what you are seeing is a JAXB issue, but an issue in the JSON binding layer that you are using .
    • 1 Also since JAXB is the default binding layer for JAX RS you can just return a JAXB model class and the JAX RS implementation will leverage JAXB to convert it to XML: service part 35 html .
    • EclipseLink JAXB (MOXy) offers native JSON binding (I'm the MOXy lead) with it you could do something like: CODESNIPPET JAVA6 .
    • Here is a complete example of how this can be done with EclipseLink JAXB (MOXy): moxy html .
    • Also, you do not have to use JAXB annotations, unless you either want to use JAXB, or another package that can also use them: Jackson, for example, supports its own annotations as well as JAXB ones .
    • My classes have jaxb annotations and the system application provider seems to interfere with the jackson json provider .
    • I am successfully marshaling a POJO into JSON using JAX RS and JAXB annotations .
    • JAXB is for XML, are you confusing it with JAX RS?.
    • With the reference JAXB implementation this works fine in both XML and JSON (we were using Jackson for the JSON logic) .
    • My classes have jaxb annotations and the system application provider seems to interfere with the jackson json provider .
    • I'd recommend JAXB Jackson .
    • My classes have jaxb annotations and the system application provider seems to interfere with the jackson json provider .
    • What does your JAXB annotated model look like?.
    • Setting the Download object to be a JAXB annotated class should solve the problem .
    • It is possible that Jackson will behave similar to Jettison with respect to the JAXB annotations I simply didn't have the time to try it .
    • Ok, no solution found with Jettison (I'm convinced it's a bug) and JAXB mapping for JSON .
    • EclipseLink JAXB (MOXy) offers native support for JSON .
    • Here is a complete example of how this can be done with EclipseLink JAXB (MOXy): moxy html .
    • For EclipseLink JAXB (MOXy) 's JSON binding, the correct mapping would be the following .
    • Here is a complete example of how this can be done with EclipseLink JAXB (MOXy): moxy html .
    • EclipseLink JAXB (MOXy) provides native JSON binding support .
    • Here is a complete example of how this can be done with EclipseLink JAXB (MOXy): moxy html .
    • This manual could be useful for you: json html#json jaxb approach section link .
    • It was a problem with jaxb .
    • please specify your question more you might want to have a look at JAXB .
    • It was a problem with jaxb .
    • i have a class like : CODESNIPPET JAVA1 .
    • I get the following error with JSON: CODESNIPPET JAVA2 .
    • Added the context resolver to your client CODESNIPPET JAVA2 .
    • I get the following error with JSON: CODESNIPPET JAVA2 .
    • So to model it, you need something like this: CODESNIPPET JAVA1 .
    • I get the following error with JSON: CODESNIPPET JAVA2 .
    • With JAXB there are two type's of List supported .
    • It was a problem with jaxb .
    • Given a class like this: CODESNIPPET JAVA1 .
    • I get the following error with JSON: CODESNIPPET JAVA2 .
    • and then your method would look like this: CODESNIPPET JAVA2 .
    • I get the following error with JSON: CODESNIPPET JAVA2 .
    • It also supports JAXB annotations just like Jettison .
    • Ok, no solution found with Jettison (I'm convinced it's a bug) and JAXB mapping for JSON .
    • and the Resource looks like this: CODESNIPPET JAVA3 .
    • I get the following error with JSON: CODESNIPPET JAVA2 .
    • whereas the best I can get it CODESNIPPET JAVA12 .
    • I get the following error with JSON: CODESNIPPET JAVA2 .
    • Here is a simple pojo CODESNIPPET JAVA1 .
    • I get the following error with JSON: CODESNIPPET JAVA2 .
    • I cant seem to post JSON to my webservice but XML works fine: CODESNIPPET JAVA1 .
    • I get the following error with JSON: CODESNIPPET JAVA2 .
    • You may be interested in the JSON support we've added to EclipseLink JAXB (MOXy) .
    • Here is a complete example of how this can be done with EclipseLink JAXB (MOXy): moxy html .
    • This is how the JAXB works .
    • It was a problem with jaxb .
Summaries of opinions about based on specific API aspects, such as, performance, usability, etc. The 'Overview' page provides an overview of the aspects detected in the opinions. The 'Trend' page shows the distribution of polarity over time for each aspect. The 'Positive Opinions' page groups positive opinions by the detected aspects. The 'Contrastive By Aspect' page shows paris of contrastive opinions under each aspect (where found).
Features:
  • What does your JAXB-annotated model look like?
  • Have to go, sorry.
Portability:
  • N/A
  • BTW String is also an Object so your Android client (about which you should give some info if that is the problem) should work.
Documentation:
  • I found a blog article from the person you mentionned and it works.
  • Here is a complete example of how this can be done with EclipseLink JAXB (MOXy): URL_http://blog.bdoughan.com/2011/08/json-binding-with-eclipselink - moxy.html.
Community:
  • Hope it helps.
  • N/A
Onlysentiment:
  • Great.
  • Thanks for quick response I am facing javax.xml.bind.JAXBException: property "eclipselink.media-type" is not supported exception.
Performance:
  • The collect of phone numbers is of size 1 and is correctly bound by square brackets.
  • Since I am more familiar with Jackson, here are some aspects where I think Jackson has more complete support than Gson (apologies if I miss a Gson feature): Extensive annotation support; including full inheritance, and advanced "mix-in" annotations (associate annotations with a class for cases where you can not directly add them) Streaming (incremental) reading, writing, for ultra-high performance (or memory-limited) use cases; can mix with data binding (bind sub-trees) -- EDIT latest versions of Gson also include streaming reader Tree model (DOM-like access); can convert between various models (tree <-> java object <-> stream) Can use any constructors (or static factory methods), not just default constructor Field and getter/setter access (earlier gson versions only used fields, this may have changed) Out-of-box JAX-RS support Interoperability: can also use JAXB annotations, has support/work-arounds for common packages (joda, ibatis, cglib), JVM languages (groovy, clojure, scala) Ability to force static (declared) type handling for output Support for deserializing polymorphic types (Jackson 1.5) -- can serialize AND deserialize things like List correctly (with additional type information) Integrated support for binary content (base64 to/from JSON Strings) .
Bug:
  • If the value is coming as 1234AS in this case returns with double quote.How to fix this and making sure its always has double quotes.
  • The exception being thrown is an RI exception (com.sun.xml.internal.bind.v2.runtime package) so EclipseLink MOXy is not being picked up as the JAXB provider.
Usability:
  • yes I see that before sending the request an OPTIONS call is send It's normal now I decided to make it as simple with text/xml and mapped it to objects with jaxb .thanks anyway.
  • Yeah., But sometimes I may need to marshall objects which has @Entity annotation too., In that case it will conflict if I try to wrap it in JAXBElement.
  • Features: 62
    1. unmarshalling: 1
      • I insist on unmarshalling to this structure: CODESNIPPET_JAVA1 .. details
    2. return: 1
      • @Molly Usually you can do whatever you want with the values you receive and return anything you want, no matter if it's GET or POST.. details
    3. string: 1
      • So, can I do something like: @GET @Path("/userinfo/{id}") @Produces({"application/xml", "application/json"}) public String getUserInfo(@PathParam("id") String id) {String users null;User user null;user new UserManager().getUserInfo(id); JAXBContext jaxbContext JAXBContext.newInstance(User.class);Marshaller jaxbMarshaller jaxbContext.createMarshaller(); jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);jaxbMarshaller.marshal(user, System.out); users jaxbMarshaller.toString(); return users;} .. details
    4. service: 1
      • Maybe I wasn't specifying the MediaType in the invocation of the service ;) thanks.. details
    5. jaxb: 7
      • My jaxb annotated class looks like this: CODESNIPPET_JAVA2 .. details
      • This is how the JAXB works.. details
      • EclipseLink JAXB (MOXy) offers native JSON-binding (I'm the MOXy lead) with it you could do something like: CODESNIPPET_JAVA6 .. details
      • Make a JAXB context resolver like this CODESNIPPET_JAVA1 .. details
      • For this example I'm just using the standard JAXB (JSR-222) annotations which have are available in the JDK/JRE since Java SE 6.. details
      • Please advise the best pattern for serialising JAXB Lists.. details
      • EclipseLink JAXB (MOXy) provides native JSON-binding support.. details
    6. list: 1
      • Yeah, sometimes it's the answers lower-down on the list that actually end-up working.. details
    7. controller: 1
      • Based on some arbitration parameter let the controller inject the correct serializer CODESNIPPET_JAVA3 .. details
    8. subclass: 1
      • The above should get you started... Also, you would need to mark each subclass like so: CODESNIPPET_JAVA2 .. details
    9. general: 27
      • What does your JAXB-annotated model look like?. details
      • @RSyed - I also have an example on GitHub that you may find helpful: URL_https://github.com/bdoughan/blog20110819 .. details
      • can you please give an example.. details
      • Please note that on processRequest() I'm currently producing a text response, but that will be changed later to produce a JSON.. details
      • can you please tell me , on what area i can find the overhead between two test.. details
      • Adding jackson-xc-1.9.2.jar solve this warrning below java.lang.NoClassDefFoundError: org/codehaus/jackson/xc/JaxbAnnotationIntrospector I hope this helps somebody.. details
      • Please help .. details
      • Your implementation is decent enough.. details
      • I still wonder if there is an even simpler way!.. details
      • Thanks, I updated to the code with my Customer class.. details
      • Fantastic, got it working as per suggestion.. details
      • Please clarify your question.. details
      • The URL_http://jcp.org/en/jsr/detail?id=222 [JAXB-(JSR-222)] specification does not cover JSON-binding so this type of support is beyond the spec.. details
      • and the Resource looks like this: CODESNIPPET_JAVA3 .. details
      • Note sadly that URL_http://stackoverflow.com/questions/5794713/java-util- map-to-json-object-with-jersey-jaxb-jackson [Java.util.Map-to-JSON-Object- with-Jersey-/-JAXB-/-Jackson] was not helpful, though it showed great promise.. details
      • So it looks something like this: CODESNIPPET_JAVA4 .. details
      • However, of course, it returns all the Employee attributes in the employees list, like this: CODESNIPPET_JAVA6 .. details
      • and the relevant resource signature looks like this: CODESNIPPET_JAVA2 .. details
      • I have a JAXBContextResolver (an implementation of ContextResolver) that looks like this: CODESNIPPET_JAVA4 .. details
      • Thanks to URL_http://stackoverflow.com/questions/2199453/how-can-i-customize- serialization-of-a-list-of-jaxb-objects-to-json/3143214#3143214 [How-can-I -customize-serialization-of-a-list-of-JAXB-objects-to-JSON?]. details
      • This involves creating a CODETERM2 like this: CODESNIPPET_JAVA1 .. details
      • Something like CODESNIPPET_JAVA4 .. details
      • Quite honest comparison, regarding your position.. details
      • please specify your question more... you might want to have a look at JAXB.. details
      • edit: I asked my question another way to try to make it clear: URL_http://stackoverflow.com/questions/5881058/how-to-map-a-bean-structure- to-a-different-schema-with-jax-rs [how-to-map-a-bean-structure-to-a-different- schema-with-jax-rs] .. details
      • MappedBuilder builder JSONConfiguration.mapped(); builder.arrays("industries"); builder.rootUnwrapping(true); this.context new JSONJAXBContext(builder.build(), Company.class); } .. details
      • I want something like this: {"id":"0","industries":[{"id":"0","name":"Technologies"}],"name":"Google Inc."} But I get: {"id":"0","industries":{"id":"0","name":"Technologies"},"name":"Google Inc."} Here is my Entity: CODESNIPPET_JAVA1 .. details
    10. maven: 1
      • We're working on improving our Maven setup.. details
    11. json: 9
      • JSON binding with JAXB and Jackson in standalone JavaSE app.. details
      • JSON OUTPUT** Note how the CODETERM7 value for the CODETERM8 key is represented as proper JSON.. details
      • You may be interested in the JSON support we've added to EclipseLink JAXB (MOXy).. details
      • Your JAXB bean is a perfectly reasonable representation of your JSON data.. details
      • The URL_http://jcp.org/en/jsr/detail?id=222 [JAXB-(JSR-222)] spec does not cover JSON binding so the answer ultimately comes down to how/if your JAX-RS implementation interprets JAXB metadata to produce/consume JSON.. details
      • Even though the CODETERM3 field was mapped with CODETERM4 there are no special indication of this in the JSON message.. details
      • Therefore, my desired JSON response would look something like this: CODESNIPPET_JAVA5 .. details
      • For URL_http://www.eclipse.org/eclipselink/moxy.php [EclipseLink-JAXB-(MOXy)] 's JSON binding, the correct mapping would be the following.. details
      • It will correctly marshal collections of size 1 wrapped as a JSON array.. details
    12. client: 2
      • Added the context resolver to your client CODESNIPPET_JAVA2 .. details
      • But if I try to transfer a primitive, like String, Integer, Boolean, etc... Client CODESNIPPET_JAVA2 .. details
    13. result: 1
      • Will result in: { "book" : { "title" : "hello" } } Both org.eclipse.persistence.moxy-2.5.1.jar and org.eclipse.persistence.core-2.5.1.jar are needed on the classpath.While playing around with this myself, I ran into: URL_http://stackoverflow.com/tags/jaxb/hot [hottest-JAXB-answers] .. details
    14. jackson: 1
      • @Jaroslaw.zawila I hoped in Jackson there is an annotation like XmlJavaTypeAdapter in jaxb.. details
    15. response: 2
      • (@XmlElement(nillable=true) Which makes the response look like, CODESNIPPET_JAVA3 .. details
      • The response looks like this CODESNIPPET_JAVA2 .. details
    16. element: 2
      • Note how the CODETERM1 attribute is used on the CODETERM2 element to indicate a CODETERM3 value.. details
      • I tried setting xml element attribute nillable true.. details
    17. class: 3
      • i have a class like : CODESNIPPET_JAVA1 .. details
      • The JAXB-annotated model class is like this: CODESNIPPET_JAVA3 .. details
      • Given a class like this: CODESNIPPET_JAVA1 .. details
  • Documentation: 19
    1. jackson: 1
      • If you update Jackson to 2.0 it is not deprecated: URL_http://fasterxml.github.com/jackson- databind/javadoc/2.0.0/com/fasterxml/jackson/databind/ObjectMapper.html [ URL_http://fasterxml.github.com/jackson - databind/javadoc/2.0.0/com/fasterxml/jackson/databind/ObjectMapper.html] You can see my configuration here (Spring): URL_http://stackoverflow.com/questions/12514285/registrer- mappingjackson2httpmessageconverter-in-spring-3-1-2-with-jaxb-annotati [Registrer-MappingJackson2HttpMessageConverter-in-Spring-3.1.2-with-JAXB- annotations] .. details
    2. jaxb: 4
      • Please read URL_http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html [this-blog] , at the bottom you will find how it's done without CODETERM2 .Also go through the answers in the post URL_http://stackoverflow.com/questions/819720/no-xmlrootelement-generated-by- jaxb [No-@XmlRootElement-generated-by-JAXB] .. details
      • For more information on StAXON's JAXB support, refer to the URL_https://github.com/beckchr/staxon/wiki/Using-JAXB [Using-JAXB] wiki page.. details
      • URL_http://blog.bdoughan.com/2011/08/json-binding-with-eclipselink-moxy.html [ URL_http://blog.bdoughan.com/2011/08/json-binding-with-eclipselink-moxy.html ] In addition to the JAXB annotations MOXy extensions (such as @XmlPath) are supported making it even easier to have one annotated model that can be used for both XML and JSON: URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html?m=0 [ URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html?m=0 ] .. details
      • Skaffman, I've tried registering a JAXB annotation introspector following the spec ( URL_http://wiki.fasterxml.com/JacksonJAXBAnnotations ) but I don't see how to dynamically plug that into my restful framework (RESTEasy).. details
    3. mapping: 1
      • I was struggling with this as well, but this question is similar and the answer works URL_http://stackoverflow.com/questions/3422545/binding-a-generic- java-class-to-a-json-using-jaxb [Binding-a-Generic-Java-Class-to-a-JSON-using- JAXB] It's a fairly simple answer although I'd struggle to explain why or how it works and doesn't cause the mapping to occur.. details
    4. general: 6
      • I found a blog article from the person you mentionned and it works.. details
      • I created a new question for this that I'd like you to answer here: URL_http://stackoverflow.com/questions/18646747/how-to-produce-json-output-with - jersey-1-17-1-using-jaxb This can help others.. details
      • I tried to get some inputs from the question I posted URL_http://stackoverflow.com/questions/15563351/how-to-dynamically-generate- and-retrieve-json-in-java-code [here] But could not really get any solution.. details
      • This manual could be useful for you: URL_http://jersey.java.net/nonav/documentation/latest /json.html#json.jaxb.approach.section [link] .. details
      • I would recommend you to take a look at the following discussion regarding its internals URL_http://stackoverflow.com/questions/1071749/how-to-reuse-jerseys-json-jaxb- for-serialization [related-post] .. details
      • Thanks for the link, Blaise.. details
    5. json: 4
      • EclipseLink JAXB (MOXy) offers support for all JAXB constructs in our JSON- binding implementation and it may be a better fit for you use case: URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html [ URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html ] Below is a link to some official Jersey examples that leverage MOXy as the JSON provider: URL_https://github.com/jersey/jersey/blob/master/examples/json-moxy/README.html [ URL_https://github.com/jersey/jersey/blob/master/examples/json-moxy/README.html ] .. details
      • Below is an example where the same object model is mapped to two different weather services (Google and Yahoo) URL_http://blog.bdoughan.com/2011/09/mapping-objects-to-multiple-xml-schemas.html [ URL_http://blog.bdoughan.com/2011/09/mapping-objects-to-multiple-xml-schemas.html ] MOXy also supports both XML and JSON binding: URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html [ URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html ] MOXy also integrates easily with JAX-RS implementations: URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html [ URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html ] .. details
      • EclipseLink JAXB (MOXy)** supports mapping a single object model to both XML and JSON with the same metadata: URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html [ URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html ] License Information** URL_http://wiki.eclipse.org/EclipseLink/FAQ/General#How_is_EclipseLink_Licensed.3F [ URL_http://wiki.eclipse.org/EclipseLink/FAQ/General How_is_EclipseLink_Licensed.3F] DOMAIN MODEL** Below is the domain model we will use for this example.. details
      • I had a go at creating a schema from the example json I had but didnt get it working for al but the simplest example.. details
    6. jax-rs: 1
      • JAX-RS Integration** MOXy includes the MOXyJsonProvider class that makes it easy to configure in your JAX-RS application: URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html [ URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html ] .. details
    7. jettison: 1
      • Jettison is an interesting library but there are some issue you will encounter using it: URL_http://blog.bdoughan.com/2011/04/jaxb-and-json-via-jettison.html [ URL_http://blog.bdoughan.com/2011/04/jaxb-and-json-via-jettison.html ] Demo Only the standard Java SE APIs are used.. details
    8. jersey: 1
      • Take a look at the URL_https://jcp.org/aboutJava/communityprocess/final/jsr339/index.html [JAX- RS-spec] or Jersey User Guide especially section devoted to URL_https://jersey.java.net/documentation/latest/media.html#json [JSON] ( URL_https://jersey.java.net/documentation/latest/media.html#d0e6192 [JAXB- based-JSON-support] ).. details
  • Community: 6
    1. general: 6
      • Hope it helps.. details
      • Send Us Your Feedback** We like to get feedback on changes we make, especially on streams that are still in development.. details
      • Since answering these questions will necessarily involve more community input than we've had yet since the project is so new, I was thinking we'd wait until a post-1.0 release to add XML support.. details
      • With JAXB there are two type's of CODETERM1 supported.. details
      • Apache Jersey has decent JAXB support.. details
      • I hope it helps you... .. details
  • Onlysentiment: 39
    1. jaxb: 1
      • I'd recommend JAXB + Jackson.. details
    2. general: 38
  • Performance: 2
    1. general: 2
      • The collect of phone numbers is of size 1 and is correctly bound by square brackets.. details
      • EDIT: I guess i'm looking for what produces smaller files and operates faster.. details
  • Bug: 8
    1. general: 8
      • If the value is coming as 1234AS in this case returns with double quote.How to fix this and making sure its always has double quotes.. details
      • I have opened the following enhancement request to make this use case even easier to handle: URL_http://bugs.eclipse.org/406375 [ URL_http://bugs.eclipse.org/406375 ] .. details
      • I've fixed the factory method for others to see, I hope you don't mind.. details
      • Also note the collection of size one was correctly represented as a JSON array (a problem with some other approaches).. details
      • Actually no because the json response is not an array of objects but an object which contains an key "dossiers" and a array as the value.. details
      • Put some assertions to check not null** objects and list not empty**.. details
      • any effort put into resolving this issue?. details
      • Rather it is due to whatever processes JAXB annotations, and how it chooses to handle null values of Java objects.. details
  • Usability: 241
    1. hashmap: 1
      • Is their a good way to export a mixed HashMap list?. details
    2. eclipse: 1
      • You can also use JPA annotations on the same objects and a JPA provider like Eclipse Link for a lot of your database needs.. details
    3. deserialization: 1
      • Many also allow you to use standard object binding methodologies such as URL_http://www.oracle.com/technetwork/articles/javase/index-140168.html [JAXB] do define your deserialization mappings using annotations.. details
    4. request: 2
      • I have opened the following enhancement request to make this use case even easier to handle: URL_http://bugs.eclipse.org/406375 [ URL_http://bugs.eclipse.org/406375 ] .. details
      • @TomAnderson - I have entered an enhancement request to support this use case.. details
    5. twitter: 1
      • So I launch a simple request to Twitter : CODESNIPPET_JAVA1 .. details
    6. eclipselink: 1
      • Works fine, but I have to do it in this way inside the resource method: JAXBContext context JAXBContextFactory.createContext(new Class[] {ONIXMessage.class}, null); How can I fetch the eclipselink JAXBContext from Jersey?. details
    7. rest: 1
      • We have a whole set of JAX-RS REST services running on top of Apache CXF and Jackson.We use JAXB annotations to take care of marshalling POJOs to JSON, works great.. details
    8. general: 61
      • You simple need add @Produces("application/xml") or headers section with content similar to this: headers {Const.HEADER_CONTENT_TYPE_APPLICATION_JSON} to your @RequestMapping.. details
      • I found a blog article from the person you mentionned and it works.. details
      • Thanks a a lot for your help.. details
      • I created a new question for this that I'd like you to answer here: URL_http://stackoverflow.com/questions/18646747/how-to-produce-json-output-with - jersey-1-17-1-using-jaxb This can help others.. details
      • If this is what your environment is doing the using JAXBElement is the correct thing to do.. details
      • I think I will modify the question a bit so that it is easy to understand.. details
      • Searching SO and Google for this has not been helpful, and thought I'd bring this to the geniuses at SO for some help.. details
      • Thanks a lot,that really helps.. details
      • and it works.. details
      • Because of the XML (as I want the same behaviour for XML as well) there is necessity to use @XmlEnumValue etc.. details
      • Both status() and echo() are working properly.. details
      • Thank You so much for your reply.. details
      • Thank U so much for your response.. details
      • I discovered that when I remove the JAXBElement type from the WS, that it works.. details
      • Demo Code** Below is a standalone example you can run to prove that everything works: CODESNIPPET_JAVA3 .. details
      • When the CODETERM8 is equal to CODETERM9 the CODETERM10 value is not marshalled.. details
      • It addresses JAXBAnnotationIntrospector and JacksonAnnotationIntrospector as well.... details
      • ex: if status != "deleted" -> bind all fields CODESNIPPET_JAVA2 .. details
      • I've fixed the factory method for others to see, I hope you don't mind.. details
      • I tried to get some inputs from the question I posted URL_http://stackoverflow.com/questions/15563351/how-to-dynamically-generate- and-retrieve-json-in-java-code [here] But could not really get any solution.. details
      • Thanks that works.. details
      • Ah should have seen this I was looking at my initialcontext method rather than my marshaller initialization, disabled Marshaller.JAXB_FORMATTED_OUTPUT and it now works.. details
      • Thankyou that works (actually the attribute is ended though there can be an end attribut eas well that I didn't show), thanks again for all your help on this.. details
      • Also note how the CODETERM9 key doesn't contain any special indicator corresponding to it being an XML attribute in the XML representation.. details
      • The problem is that it's only working for the CODETERM4 property and not the CODETERM5 property.. details
      • It's almost perfect.. details
      • No, but I'll look into it, thanks!.. details
      • and then your method would look like this: CODESNIPPET_JAVA2 .. details
      • To pass your specialized JSONJAXBContext to Jersey, you will finally need to implement a JAXBContext ContextResolver: CODESNIPPET_JAVA1 .. details
      • Send Us Your Feedback** We like to get feedback on changes we make, especially on streams that are still in development.. details
      • Additionally my API needs to support both XML and JSON.. details
      • Everything is working fine except that the generated responses contain the setters info e.g.. details
      • Things to note about the JSON: The CODETERM5 value is used to represent that the CODETERM6 is null.. details
      • The CODETERM8 of type CODETERM9 was correctly marshalled without quotes.. details
      • The collect of phone numbers is of size 1 and is correctly bound by square brackets.. details
      • So far I have been creating inner classes to support the wrapper, though I don't like the plumbing as it were as I then need to do it for every pojo.. details
      • As you can see the CODETERM8 value appears without quotes: CODESNIPPET_JAVA6 .. details
      • Since answering these questions will necessarily involve more community input than we've had yet since the project is so new, I was thinking we'd wait until a post-1.0 release to add XML support.. details
      • Priorities could obviously change if there's enough momentum in that direction, but I just don't see it happening in the next week.. details
      • Demo Below is a standalone example you can run to prove everything works.. details
      • Demo Below is some standalone code to demonstrate the reading/writing of the JSON.. details
      • So to model it, you need something like this: CODESNIPPET_JAVA1 .. details
      • Note that I'm not saying this solution is optimal, just what has worked for us.. details
      • It seems pretty basic, but I haven't been able to find any examples online (maybe I'm google searching the wrong things).. details
      • You can add the necessary supporting APIs if you are using Java SE 5.. details
      • I'm open to trying other ContextResolvers/Serializers, but I haven't been able to find one that works, so code examples would be nice.. details
      • You can change this behaviour by setting the CODETERM2 property on CODETERM3 to true.. details
      • This manual could be useful for you: URL_http://jersey.java.net/nonav/documentation/latest /json.html#json.jaxb.approach.section [link] .. details
      • (That works rather well in practice.). details
      • You then need to work out whether the URI refers to something you know (i.e., resolve the URI and see if it points into yourself) and deal with the fragment identifier.. details
      • The above example works, so, please, be more precise.. details
      • I don't know very well JaxB, and indeed both libraries are pretty close (with the big advantage of the "standardization" for JaxB).. details
      • Summary is not present as an attribute in the received json, but as a value of the "fields" attribute.. details
      • Just make sure your pojos are annotated correctly.. details
      • It also URL_http://docs.codehaus.org/display/JACKSON/Jackson+JAXB+Support [supports- JAXB-annotations] just like Jettison.. details
      • You got it, but works if I leave XML beans out.. details
      • your blog is useful!.. details
      • Perhaps its support was not enabled: URL_http://wiki.fasterxml.com/JacksonJAXBAnnotations .. details
      • I want it to be like, CODESNIPPET_JAVA4 .. details
      • But, instead, I have to pass in something like this: CODESNIPPET_JAVA4 .. details
      • URL_https://jaxb.dev.java.net/guide/Mapping_your_favorite_class.html#HashMap ["JAXB-spec-defines-a-special-handling-for-Map-when-it's-used-as-a-property- of-a-bean."]. details
    9. boolean: 1
      • thanks your suggestion of changing it to Boolean worked.. details
    10. null: 3
      • @theSshow - I was suggestion if you couldn't make the boolean property Boolean (to support a null value), then you could create an AdaptedEmployee class (it should not extend Employee to use with the XmlAdapter (see URL_http://blog.bdoughan.com/2010/12/jaxb-and-immutable - objects.html).. details
      • Both fields had null values.. details
      • It will by default include null values for properties, although this is configurable in case you want to suppress nulls.. details
    11. data: 1
      • It isn't a generic data modeling framework with flexible bindings.. details
    12. marshalling: 1
      • Update: I confirmed that CODETERM9 marshalling is indeed working for scalar CODETERM10 properties by adding a scalar CODETERM11 property and observing the expected output in the JSON.. details
    13. jackson: 14
      • The simplest way of doing this is to use JAXB to create the tooled version of the structure (with something like Jackson as the serialization engine) and then to create a factory method somewhere that will make the structure for you without you having to specify anything extra yourself.. details
      • I tried to use Jackson with JAXB module to convert JAXB-object into JSON, which works pretty fine with storing the data.. details
      • It is possible that Jackson will behave similar to Jettison with respect to the JAXB annotations I simply didn't have the time to try it.. details
      • You can use one or two tools for this: one common combination is to use Jackson for JSON, and JAXB for XML, to use their respective strengths.. details
      • I'm just putting forward my solution (using JAXB), as I have used it to solve issues like his when I was using the Jackson lib.... details
      • Jackson supports a subset of JAXB metadata and does not currently support the CODETERM1 class.. details
      • Jersey uses serialization frameworks like JAXB (xml) and Jackson (json, bson, xml, csv) for actual reading/writing of content.. details
      • So, you've got two choices: 1. configuring JAXB to be more standard ( URL_http://stackoverflow.com/questions/1145476/how-do-i-marshal-nested-lists-as-json-using-jersey-i-get-an-array-of-nulls-or-a [see-here] for more); 2. using Jackson instead of JAXB which I recommend.. details
      • Looks like you are making use of JAXB for XML and Jackson for JSON.. details
      • I would recommend using URL_http://jackson.codehaus.org [Jackson] as it is superior to other recommended alternatives when producing JSON, and for XML either: Use a JAXB implementation with JAXB annotations (Jackson can optionally support JAXB annotations as well, so very little overhead of 2 libs) Use URL_https://github.com/FasterXML/jackson-xml-databind [Jackson-xml-databind] module to produce XML using Jackson itself (in format that is usually identical to JAXB produced) I do NOT think that you absolute must use a single library or framework, and the result is often better if you just choose best choice for each separately.. details
      • GSON from google : URL_http://code.google.com/p/google-gson/ [ URL_http://code.google.com/p/google-gson/ ] , or Jackson the library used in spring : URL_http://jackson.codehaus.org/ [ URL_http://jackson.codehaus.org/ ] and I would concur with others suggesting jaxb for XML to pojo, well supported lots of tools : its the standard.. details
      • Finally, Jackson supports JAXB annotations if you must use them (for example, when using JAXB for producing XML).. details
      • @Colin: I just said that Jackson supports JAXB annotations as well.. details
      • Not straightforward, but I'd combine JAXB, Jackson and BeanUtils.. details
    14. jax-rs: 3
      • JAX-RS and CODETERM6 MOXy includes an implementation of CODETERM7 / CODETERM8 which makes it easy to configure MOXy as your JSON-binding provider.. details
      • You can change this by setting a configured instance on a JAX-RS CODETERM10 class like the one below.. details
      • JAX-RS Integration** MOXy includes the MOXyJsonProvider class that makes it easy to configure in your JAX-RS application: URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html [ URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html ] .. details
    15. classpath: 1
      • I really find SimpleXML a good tool, no jar / classpath problems, easy to use (as is JaxB), pretty fast, good error reporting when somethings goes wrong (XML element not mapped for example), and so on.. details
    16. json: 58
      • Note too that you need not use JAXB -- JAXB is for producing XML (altough there are impls that do some form of JSON output as well).. details
      • @chrylis, it's far from trivial to constuct an elaborate java structure which can serialize to both pretty json and pretty xml.. details
      • Normally mapping of JSON to POJOs works with JAXB without creating an own messageBodyReader, because the message reader for JSON already exists.. details
      • :-) JAXB is cool, but I think I'd do discription.substring(1, discription.length()-1) before converting JSON into XML just for the output.. details
      • Since it converts StAX events to/from JSON it can be used with an XML binding tool (JAXB is the standard) to produce JSON from objects.. details
      • You basically need to add a provider for JSON support, like f.e.. details
      • Any help would be most appreciated, (de)serialization with JSON and XML with json.org, Jackson, and JAXB has turned into a black and bottomless pit that has consumed almost a month of my life.. details
      • I would like to use JAXB in a JavaSE standalone application to read and write Json files.I managed to do it for XML files with my snippet below, but I don't understand how to switch to Json: CODESNIPPET_JAVA1 .. details
      • With the reference JAXB implementation this works fine in both XML and JSON (we were using Jackson for the JSON logic).. details
      • I have a POJO with JAXB annotations, it works well marshalling to xml and json, however, the xml and json are not compatible since the root tag is lost in json.. details
      • Also, since content has an @XmlValue annotation in the oxm.xml for the JSON binding it can be changed to be handled instead as a regular element (and name it value or whatever you want to call it).. details
      • But, how do I now ensure that the JSON response returns the value as a JavaScript boolean type, instead of a string (i.e.. details
      • Also note the collection of size one was correctly represented as a JSON array (a problem with some other approaches).. details
      • The EclipseLink MOXy** implementation of JAXB offers native JSON binding meaning that items like collections of size 1 will be properly converted to JSON.. details
      • Thanks, btw I saw your blog before (nice one), when I've tried to search a solution to my issue, I just didn't want to change the json provider right now since I'm at the end of the project sprint.. details
      • I'm trying to write a code which can take either xml or JSON input and out JSON or XML respectively.. details
      • The point being: JAXB does not have any concept of JSON, so any support for JSON relies on retrofitting JSON to an XML model of the world (StaX).. details
      • This would be useful as I do not believe what you are seeing is a JAXB issue, but an issue in the JSON binding layer that you are using.. details
      • We make the value of these keys JSON arrays since keys are not allowed to repeat.. details
      • To get this JSON representation you have mapped your model with the CODETERM1 annotation which tells JAXB to use the value of the CODETERM2 annotation as the inheritance indicator.. details
      • Appendix D.3 of JAXB 2.1 specs says that the conversion to uppercase _must_ be done, hence you probably should hope that json marshaling offers something.. details
      • EclipseLink JAXB (MOXy) offers support for all JAXB constructs in our JSON- binding implementation and it may be a better fit for you use case: URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html [ URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html ] Below is a link to some official Jersey examples that leverage MOXy as the JSON provider: URL_https://github.com/jersey/jersey/blob/master/examples/json-moxy/README.html [ URL_https://github.com/jersey/jersey/blob/master/examples/json-moxy/README.html ] .. details
      • My web application works fine (I'm able to successfully access other resources) but this one resource (that I pass my JSON to) returns a 415 Media Type Unsupported exception.. details
      • If you don't use JAXB annotated objects, but simple POJO's, you can get the correct behaviour by simply enabling the POJO mapping feature, together with the Jackson JSON library.. details
      • Actually no because the json response is not an array of objects but an object which contains an key "dossiers" and a array as the value.. details
      • Below is an example where the same object model is mapped to two different weather services (Google and Yahoo) URL_http://blog.bdoughan.com/2011/09/mapping-objects-to-multiple-xml-schemas.html [ URL_http://blog.bdoughan.com/2011/09/mapping-objects-to-multiple-xml-schemas.html ] MOXy also supports both XML and JSON binding: URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html [ URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html ] MOXy also integrates easily with JAX-RS implementations: URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html [ URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html ] .. details
      • The stack trace clearly indicated that a JAXB implementation was being used with the JSON and MOXy supports more JAXB annotations than Jackson does.. details
      • In the XML representation CODETERM10 was an attribute, but in the JSON representation there is not need for it to be specially represented.. details
      • EclipseLink JAXB (MOXy)** supports mapping a single object model to both XML and JSON with the same metadata: URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html [ URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html ] License Information** URL_http://wiki.eclipse.org/EclipseLink/FAQ/General#How_is_EclipseLink_Licensed.3F [ URL_http://wiki.eclipse.org/EclipseLink/FAQ/General How_is_EclipseLink_Licensed.3F] DOMAIN MODEL** Below is the domain model we will use for this example.. details
      • I'm using this in a Spring/MVC RESTful application where I need to support both JSON and XML.. details
      • The CODETERM7 mechanism was used to specify that the CODETERM8 field had a CODETERM9 value, this has been translated to the proper null representation in the JSON output.. details
      • Now, I also like to generate JSON files after this line.. details
      • Can I create one class, annotate it with JAXB annotations(for XML support) and declare in web.xml for JSON (Jackson library) support?. details
      • ( URL_https://groups.google.com/d/topic/google-appengine- java/uImBt6fOhww/discussion%20original [original] ) I have put together a simple json REST service using jersey, jaxb and jackson.. details
      • The Xml is fine, the json is nearly fine except that because Json directly supports arrays having elements like ipi-list and artist-list doesnt seem very json, is it possible to generate more json like json from my model ?. details
      • Generating more json like json from JAXB and Jersey.. details
      • As an alternative to Jettison, your original JSON input can be easily parsed with URL_https://github.com/beckchr [StAXON] 's CODETERM2 , which works with any JAXB implementation: CODESNIPPET_JAVA4 .. details
      • We could eliminate this class if your JSON looked like: CODETERM5 .. details
      • If you are ultimately looking for a way to interact with JSON using a JAXB (JSR-222) implementation, then the following is how it can be done using MOXy.. details
      • I had a go at creating a schema from the example json I had but didnt get it working for al but the simplest example.. details
      • or alternatively, modify json marshaling so it will use the enum "value" method instead the enum name?. details
      • Demo The standard JAXB APIs are used to do the conversions to/from JSON and XML: CODESNIPPET_JAVA2 .. details
      • Can anyone recommend some Java JSON libraries that makes a good reuse of JAXB annotations?Lightweight libraries are preferred.. details
      • Which Java JSON libraries make good reuse of JAXB annotations?. details
      • I had similar problem and I resolved it by creating custom JAXBContextResolver and manually specifying which classes are going to play nicely with json serialization: CODESNIPPET_JAVA1 .. details
      • JAX-RS supports the use of JAXB (Java API for XML Binding) to bind a JavaBean to XML or JSON and vise versa.. details
      • I cant seem to post JSON to my webservice but XML works fine: CODESNIPPET_JAVA1 .. details
      • I want to receive and emit JSON objects from Java classes like the following: CODESNIPPET_JAVA1 .. details
      • Given an entity pojo, I can annotate it with Hibernate, JAXB and JSON annotations so that the same class can be written to the database as well as serialize/deserialize for message exchange.. details
      • If I change it to CODETERM2 the JSON response will treat it as a Sting and keep the double quotes in the response.. details
      • In fact I find more clean to avoid this JSON to JAXB translation my first solution was using.. details
      • My starting framework is JBoss RESTEasy (JAX-RS implementation) that provides an elegant way to consume Rest services JSON services by mapping JSON to JAXB thru Jettison framework (it works also in the other way if you want to provide REST service and produce JSON from JAXB).. details
      • To support both JSON and XML messages do the following: CODESNIPPET_JAVA2 .. details
      • Note that we are already using a JAXB ContextResolver to URL_http://blogs.oracle.com/japod/entry/configuring_json_for_restful_web [ensure] the JSON is correct for a single row.. details
      • It has support for JAXB annotations so you would be able to work with JSON and beans generated.. details
      • For example, I'd like to be able to call POST /employee/ with a JSON thatlooks like this: CODESNIPPET_JAVA3 .. details
      • There are several ways to parse JSON with it: Streaming (like Sax) Tree (like DOM) Object-mapped (like JAXB) EDIT: Take org.json classes, there are URL_http://developer.android.com/reference/org/json/package-summary.html [already-in] the android API.. details
      • I am successfully marshaling a POJO into JSON using JAX-RS and JAXB annotations.. details
    17. spring: 1
      • In my application the JAXB output generates like: CODETERM1 this is method call to the spring Object XML Mapping Marshallers that generate XML files.. details
    18. import: 1
      • I am unable to download the jar file for import org.eclipse.persistence.jaxb.JAXBContextProperties and import org.eclipse.persistence.jaxb.MarshallerProperties which jar i have to use it will be helpfull if i know the link from where can i get it.. details
    19. moxy: 1
      • I pretty much look for anything you've written when dealing with MOXy or JAXB.. details
    20. jaxb: 55
      • JAXB is a standard that lets you translate between XML and objects.. details
      • Does JAXB support to receive values (using POST) and saving them to the database but do not returning (using GET) those values?. details
      • But I feel it like this jaxb thing is not straight forward and it could have been a little easier than the current thing.. details
      • yes I see that before sending the request an OPTIONS call is send It's normal now I decided to make it as simple with text/xml and mapped it to objects with jaxb .thanks anyway.. details
      • In the past I remember working with XML files, using the JAXB compiler to automatically generate Java classes, and those tags where automatically generated, so I guess some tools to generate code do this, while others do not.. details
      • If you used JAXB to generate your classes, you can certainly have something like @XmlElements with different types to parse a List.. details
      • I should clarify, as Perception says, JAXB was originally about mapping between Java and XML, pragmatically may implementations of JAXB also support mapping to to JSON: for example URL_http://wiki.fasterxml.com/JacksonJAXBAnnotations .. details
      • That's interesting because it seems to indicate that the only part JAXB plays in this is to lend its annotations and some other interfaces (e.g.. details
      • I tried it and the XML consisted of one empty tag only, meaning there's something about the POJO model that JAXB doesn't like.. details
      • If you want to , you can create a separate method just like this very simple (if you already have the JAXB libs) the main class CODESNIPPET_JAVA1 .. details
      • I'm using JAXB and MOXy to unmarshal structure like CODESNIPPET_JAVA1 .. details
      • EDIT: I now found this setting: USE_GETTERS_AS_SETTERS (default: true) Controls whether "getters" that return Collection or Map types can be used for "setting" values (same as how JAXB API works with XML), so that separate "setter" method is not needed.. details
      • Then use Jackson, which has JAXB support, by adding all the libraries to your project and adding this configuration: CODESNIPPET_JAVA2 .. details
      • Update: JAXB annotation are great for interop with XML system, but you should really use Jackson's own annotation if you can.. details
      • You are using JAXB annotations so you need to properly configure your CODETERM1 with the correct module; you need the URL_https://github.com/FasterXML/jackson-module-jaxb-annotations [jackson- module-jaxb-annotations] project.. details
      • There's a JAXB plugin for adding annotations: URL_http://confluence.highsource.org/display/J2B/Annotate+Plugin [ URL_http://confluence.highsource.org/display/J2B/Annotate+Plugin ] You can hook it into the CODETERM1 phase of a Maven build like so: CODESNIPPET_JAVA1 .. details
      • I've created a JAXB bean with a few simple fields along with a nested array of other jaxb beans.. details
      • Since MOXy implements that JAXB (JSR-222) specification you can be confident using it for your XML as well.. details
      • I tried it and the XML consisted of one empty tag only, meaning there's something about the POJO model that JAXB doesn't like.. details
      • That's interesting because it seems to indicate that the only part JAXB plays in this is to lend its annotations and some other interfaces (e.g.. details
      • True, the parts of the Javadoc that I omitted above include "This is identical to how JAXB handles type information annotations; and is chosen since it is the dominant use case.. details
      • Looks like getJAXBContext() in MOXyJSONProvider might not be picking up a context correctly (and thus creating a JAXB context that doesn't know what "eclipselink.media-type" is).. details
      • Below is how you an support your use case with your CODETERM1 class as annotated with EclipseLink JAXB (MOXy).. details
      • , but if you change the type of data attribute to String it will look like due to the way Jaxb handles Strings and primitives: CODESNIPPET_JAVA3 .. details
      • Note how only the standard JAXB APIs are used.. details
      • _**Demo**_ MOXy doesn't just interpret JAXB annotations it is a JAXB implementation so the standard JAXB runtime APIs are used.. details
      • I tried making a generic class like CODETERM1 and create new instances on return but JAXB appears to not like this.. details
      • Don't return Strings in your methods but Customer objects it self and let JAXB take care of the de/serialization.. details
      • 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.. details
      • 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.. details
      • Can I create one class, annotate it with JAXB annotations(for XML support) and declare in CODETERM1 CODESNIPPET_JAVA1 .. details
      • You could leverage the JSON-Binding and external mapping document in EclipseLink JAXB (MOXy) to support your use case.. details
      • For JAXB I believe you need to annotate your entity like below: CODESNIPPET_JAVA2 .. details
      • As a simple test, I return a bean of Book, and it gets output as JSON, but the JAXB object (delivery schedule) stays in an XML format.. details
      • Also, you do not have to use JAXB annotations, unless you either want to use JAXB, or another package that can also use them: Jackson, for example, supports its own annotations as well as JAXB ones.. details
      • EclipseLink JAXB (MOXy) offers native support for JSON.. details
      • For more information on StAXON's JAXB support, refer to the URL_https://github.com/beckchr/staxon/wiki/Using-JAXB [Using-JAXB] wiki page.. details
      • I prefer JAXB and work with Lists which include extra POJOs.. details
      • I'm using a JAXB adapter... CODETERM1 that formats my dates in a standard format for the JSON-consuming clients.. details
      • I have a class that has JAXB and bean validation annotations, much like the following: CODESNIPPET_JAVA1 .. details
      • If you are using JAXB in combination with JAX-RS (Java API for RESTful webservices), this is easy.. details
      • MOXy does look like a very promising candidate in XML space -- giving JAXB RI and XStream run for their money.. details
      • URL_http://blog.bdoughan.com/2011/08/json-binding-with-eclipselink-moxy.html [ URL_http://blog.bdoughan.com/2011/08/json-binding-with-eclipselink-moxy.html ] In addition to the JAXB annotations MOXy extensions (such as @XmlPath) are supported making it even easier to have one annotated model that can be used for both XML and JSON: URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html?m=0 [ URL_http://blog.bdoughan.com/2011/08/binding-to-json-xml-geocode-example.html?m=0 ] .. details
      • It seems to have good JAXB support out of the box.. details
      • I am developing a project that already uses XML serialization, so I need an elegant solution to support JSON, by reusing the JAXB annotations.. details
      • You can use Object to Xml converter like JAXB to make your life easier.. details
      • I've used org.w3c.dom.Element maybe using another one may help navigate through the response (if jaxb supports it).. details
      • Skaffman, I've tried registering a JAXB annotation introspector following the spec ( URL_http://wiki.fasterxml.com/JacksonJAXBAnnotations ) but I don't see how to dynamically plug that into my restful framework (RESTEasy).. details
      • POJO to XML** JAXB is the Java standard ( URL_http://jcp.org/en/jsr/detail?id=222 [JSR-222] ) for converting Java objects to/from XML (I am a member of the JAXB expert group): URL_http://bdoughan.blogspot.com/2010/07/jaxb-xml-binding-standard.html [ URL_http://bdoughan.blogspot.com/2010/07/jaxb-xml-binding-standard.html ] POJO to JSON** People have been using JAXB with URL_http://jettison.codehaus.org/ [Jettison] to produce JSON.. details
      • I think you should be able to just construct ObjectMapper (which does not add JAXB introspector by default), and register it via standard JAX-RS provider mechanism.. details
      • The POJO's which represent my resources are JAXB (XML) annotated simple Java classes (they are generated from a schema definition - so they have the annotations).. details
      • Rather it is due to whatever processes JAXB annotations, and how it chooses to handle null values of Java objects.. details
      • Now: simple solution for most JAX-RS implementations is to not use JAXB annotation based approach at all, but a JSON-specific serializer, such as URL_http://jackson.codehaus.org/ [Jackson] 's JacksonJsonProvider (Jackson can actually use JAXB annotations, too).. details
      • You only need something like this in your ressources (supposing DetailProduit is your object you want to serialize and that DetailProduit.java is jaxb tagged and in package.of.your.model) CODESNIPPET_JAVA2 .. details
      • For POJO to XML I suggest using URL_http://www.oracle.com/technetwork/articles/javase/index-140168.html [JAXB] (there are other libraries as well, such as XStream for example, but JAXB is standardized).. details
    21. object: 6
      • My response object is simple and uses normal annotations: CODESNIPPET_JAVA4 .. details
      • Given a model object CODETERM11 create a CODETERM12 and CODETERM13 2) Write a custom message converter I tried this and it turned out to be a bit complicated since the view must know how to resolve e.g., a CODETERM14 to a CODETERM15 to be able to serialize it into a readable format.. details
      • The object being serialized and de-serialized contains some standard objects that are stored in MySql.. details
      • Below is what your object model could look like.. details
      • I have a class CODETERM2 that has a CODETERM3 field and it's annotated with CODETERM4 When I return any User object from my resources, everything is fine.. details
      • Thanks for that but I would prefer to not use any plugs in, I know there is a simple way that I could do it with a simple for each object in the array loop.I had it going before but I cant find it again.. details
    22. mapping: 3
      • I was struggling with this as well, but this question is similar and the answer works URL_http://stackoverflow.com/questions/3422545/binding-a-generic- java-class-to-a-json-using-jaxb [Binding-a-Generic-Java-Class-to-a-JSON-using- JAXB] It's a fairly simple answer although I'd struggle to explain why or how it works and doesn't cause the mapping to occur.. details
      • Foo You can take advantage of MOXy's path based mapping for this use case.. details
      • Then you will need to override the CODETERM1 in the external mapping file as well.. details
    23. post: 1
      • Thanks, this is the solution - although I would not have understood what to do without many other similar SO Questions/Answers I found :-) I will post the detailed solution in the Question.. details
    24. parsing: 1
      • The net effect is that rather than writing lots of little getJSONObject() calls, you invest in setting up corresponding classes, this should result in nicely structured code, where the processing of the data, that is the real business logic, is separated from the parsing code, which I view as "plumbing".. details
    25. jettison: 2
      • I figured I would use URL_http://jettison.codehaus.org/ [Jettison] as it seems it would be URL_http://blog.bdoughan.com/2011/04/jaxb-and-json-via-jettison.html [easier- to-implement] since it actually works with JAXB; however, looking at URL_http://code.google.com/p/thrift-protobuf-compare/wiki/Benchmarking [Older- benchmarks] in which Jettison was not included I have found URL_http://code.google.com/p/kryo/ [Kryo] produces smaller files and Serialized and DeSerialized quicker than some alternatives.. details
      • Jettison is an interesting library but there are some issue you will encounter using it: URL_http://blog.bdoughan.com/2011/04/jaxb-and-json-via-jettison.html [ URL_http://blog.bdoughan.com/2011/04/jaxb-and-json-via-jettison.html ] Demo Only the standard Java SE APIs are used.. details
    26. class: 4
      • This code works fine if I transfer a class ( MyClass ) that has @XmlRoolElement Client CODESNIPPET_JAVA1 .. details
      • However, all subsequent requests after this work fine, the class then seems to have been loaded.. details
      • My Download class looks pretty much like this (and as I've mentioned already - this works pretty fine when used directly): CODESNIPPET_JAVA5 .. details
      • The Java class could look like the one below.. details
    27. double: 1
      • If the value is coming as 1234AS in this case returns with double quote.How to fix this and making sure its always has double quotes.. details
    28. list: 5
      • Thanks for the answer, in this third solution, the example code which is used isColumnPositionMappingStrategy strat new ColumnPositionMappingStrategy();strat.setType(YourOrderBean.class);String[] columns new String[] {"name", "orderNumber", "id"}; // the fields to bind do in your JavaBeanstrat.setColumnMapping(columns);CsvToBean csv new CsvToBean();List list csv.parse(strat, yourReader);what exactly is yourReader here, and how do I input values to bind with bean?. details
      • Put some assertions to check not null** objects and list not empty**.. details
      • There have been many questions as to how why list types are not serialising, however I'm questioning what is a good practice to serve a list type of beans in a simple way.. details
      • You can define custom serializer (and deserializer if you need it back) using @JsonSerialize(contentUsing=MySerializer.class); (contentUsing because it's to be used for List values, not List itself).. details
      • When I use a list of Strings - everything works perfectly fine!. details
    29. pojo: 2
      • I have to be honest though, I really don't like the idea of having to manage an XML file in addition to my POJO to apply the "views".. details
      • Here is a simple pojo CODESNIPPET_JAVA1 .. details
    30. time: 1
      • But actually , I have used this tool first time and I am not able to find the difference, accurately.. details
    31. root: 1
      • Fundamentally, XML (and by extension JAXB) likes to trace everything back to a single root node/object.. details
    32. jersey: 5
      • I've been able to get it working with JAXB, but I'm specifically looking for Jersey POJO writing, not JAXB writing.. details
      • Dependencies Remove both CODETERM1 (this module doesn't exist any more in Jersey 2.x) and CODETERM2 (which is only for Jersey 1.x) and add one of the modules CODETERM3 (JAXB) or CODETERM4 (POJO).. details
      • Jersey is a great JAX-RS framework, EclipseLink provides JAXB & JPA implementations and is not a Jersey replacement.. details
      • Apache Jersey has decent JAXB support.. details
      • Since this has to do with Jersey the first thing I would recommend is to avoid JAXB all together since JAXB (in context of XML or JSON) ain't HATEOAS.. details
  • Features: 24
    1. nested: 1
      • Output of project.json (see nested technologies list): CODESNIPPET_JAVA4 .. details
    2. jaxb: 4
      • The problem was the we left the old JAXB provider hanging around with it's @Provider annotation.. details
      • Problems with Your Model There are a few problems with your model: Getter with no Setter** By default JAXB Will not consider a get method without a corresponding set method as a property.. details
      • JAXB cant handle non-static inner classes.. details
      • You can leverage the @XmlPath extension in EclipseLink JAXB (MOXy) to break the relationship between then entity model and the message format (I'm the MOXy tech lead): URL_http://stackoverflow.com/questions/4889913/jaxb2-mapping-nested-elements-into-the-same-java-class/4890120#4890120 [JAXB2:-Mapping-nested-elements-into-the-same-Java-class] .. details
    3. object: 2
      • Key By specifying CODETERM2 the contents of the reference object are pulled up into the node corresponding to the source object.. details
      • I can fetch the Download object itself without any problems... CODESNIPPET_JAVA2 .. details
    4. list: 1
      • So essentially I want to merge all the relations so they are in one list and lose the relationlist label.. details
    5. general: 8
      • Have to go, sorry.. details
      • As seen here, the 'element' tag is lost in the json.. details
      • Problem was in the xjb file, for details look in the related question URL_http://stackoverflow.com/questions/12860742/jaxb-bean-generation [here] .. details
      • I'm re-asking an unanswered question from the now read-only google groups App Engine for Java because I have the exact same problem.. details
      • +1 Ahh...I see you beat me to the punch.. details
      • Doh - sorry, when making the example - I messed up the code trying to make it simpler (should have been setBiz).. details
      • I'm trying to force brackets on lists that contain only one element.. details
      • What am doing wrong here?. details
    6. json: 5
      • EDIT**:This is what Fiddler captures when I post the JSON data: CODESNIPPET_JAVA7 .. details
      • The key names in JSON will differ on the basis of annotation provided.. details
      • I am getting the following Exception when I try to marshall the java object to Json CODESNIPPET_JAVA1 .. details
      • By default URL_http://www.eclipse.org/eclipselink/moxy.php [EclipseLink- JAXB-(MOXy)] will marshal the JSON to one line.. details
      • JAXB JSON force brackets on arrays.. details
    7. file: 1
      • I have an XSD file with enumeration in lower case e.g.. details
    8. jax-rs: 1
      • _**One Line**_ By default when you include CODETERM3 in your JAX-RS application, the output will be marshalled on one line: CODESNIPPET_JAVA6 .. details
    9. configuration: 1
      • The problem is that most of what I found is for webapps, in which the part of the configuration which I need is under the hood.. details
  • Portability: 1
    1. general: 1
      • BTW String is also an Object so your Android client (about which you should give some info if that is the problem) should work.. details
  • Documentation: 20
    1. jaxb: 9
      • Here is a complete example of how this can be done with EclipseLink JAXB (MOXy): URL_http://blog.bdoughan.com/2011/08/json-binding-with-eclipselink - moxy.html.. details
      • jaxb.properties To specify MOXy as your JAXB provider you need to include a file called CODETERM1 in the same package as your domain model with the following entry (see: URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as- your.html [ URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as - your.html] ): CODESNIPPET_JAVA2 .. details
      • jaxb.properties To specify MOXy as your JAXB provider you need to include a file called CODETERM1 in the same package as your domain model with the following entry (see: URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as- your.html [ URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as - your.html] ): CODESNIPPET_JAVA3 .. details
      • FYI WebLogic switched to MOXy as the default JAXB provider: URL_http://blog.bdoughan.com/2011/12/eclipselink-moxy-is-jaxb - provider-in.html.. details
      • DEMO CODE** _**jaxb.properties**_ To specify MOXy as your JAXB provider you need to include a file called CODETERM6 in the same package as your domain model with the following entry (see: URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as- your.html [ URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as - your.html] ): CODESNIPPET_JAVA4 .. details
      • You can see full mavenized project at URL_http://code.google.com/p/jinahya/sou rce/browse/trunk/com.googlecode.jinahya/stackoverflow/ [ URL_http://code.google.com /p/jinahya/source/browse/trunk/com.googlecode.jinahya/stackoverflow/] JAXB doesn't need the setter if you control to use fields not properties.. details
      • jaxb.properties To specify MOXy as your JAXB provider you need to include a file called CODETERM7 with the followin entry (see URL_http://blog.bdoughan.com/2011/05 /specifying-eclipselink-moxy-as-your.html [ URL_http://blog.bdoughan.com/2011/05 /specifying-eclipselink-moxy-as-your.html] ): CODESNIPPET_JAVA4 .. details
      • For More Information** URL_http://blog.bdoughan.com/search/label/XmlAdapter [ URL_http://blog.bdoughan.com/search/label/XmlAdapter ] URL_http://blog.bdoughan.com/2012/04/binding-to-json-xml-handling-null.html [ URL_http://blog.bdoughan.com/2012/04/binding-to-json-xml-handling-null.html ] I noticed that you had the following comment in your code: // getters and setters with @XmlElement on each attribute Because JAXB (JSR-222) implementations are configuration by exception, you only need to add annotations where you want the XML representation from the default.. details
      • For More Information** URL_http://blog.bdoughan.com/2012/03/moxy-as-your-jax-rs-json-provider_15.html [MOXy-as-Your-JAX-RS-JSON-Provider---Client-Side] URL_http://blog.bdoughan.com/2012/03/moxy-as-your-jax-rs-json-provider.html [MOXy-as-Your-JAX-RS-JSON-Provider---Server-Side] URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as-your.html [Specifying-EclipseLink-MOXy-as-Your-JAXB-Provider] UPDATE In GlassFish 4 EclipseLink JAXB (MOXy) is the default JSON-binding provider used by Jersey: URL_http://blog.bdoughan.com/2013/06/moxy-is-new-default-json-binding.html [ URL_http://blog.bdoughan.com/2013/06/moxy-is-new-default-json-binding.html ] .. details
    2. class: 1
      • MapAdapter An CODETERM4 allows you to marshal an instance of one class as an instance of another class (see: URL_http://blog.bdoughan.com/2010/07/xmladapter-jaxbs- secret-weapon.html [ URL_http://blog.bdoughan.com/2010/07/xmladapter-jaxbs-secret - weapon.html] ).. details
    3. required: 1
      • But the actual requirement is a more complex transformation, Im not sure how to explain it in the correct terminology but here is an example of the required output.. details
    4. eclipselink: 1
      • This best mechanisms for this are: EclipseLink Forum: URL_http://www.eclipse.org/forums/index.php?t=thread&frm_id=111 [ URL_http://www.eclipse.org/forums/index.php?t=thread&frm_id=111 ] EclipseLink Users Mailing List: eclipselink-users AT eclipse.org** Enter a Bug: URL_https://bugs.eclipse.org/bugs/enter_bug.cgi?product=EclipseLink [ URL_https://bugs.eclipse.org/bugs/enter_bug.cgi?product=EclipseLink ] For More Information** URL_http://blog.bdoughan.com/2010/12/extending-jaxb-representing-annotations.html [ URL_http://blog.bdoughan.com/2010/12/extending-jaxb-representing-annotations.html ] UPDATE Thanks for the answer although I'm not convinced requiring me to add element to prop order just because I want to rename it is an improvement.. details
    5. element: 1
      • The CODETERM4 element is a complex type with simple content (see: URL_http://blog.bdoughan.com/2011/06/jaxb-and-complex-types-with-simple.html [ URL_http://blog.bdoughan.com/2011/06/jaxb-and-complex-types-with-simple.html ] ).. details
    6. general: 6
      • I'm attempting to follow the example located URL_http://stackoverflow.com/questions/14734741/converting-json-to-xml-and- vice-versa-using-jackson-api-and-jaxb-annotation [here] but get an javax.xml.bind.PropertyException.. details
      • You could do the following with CODETERM2 (see: URL_http://blog.bdoughan.com/2010/09/jaxb-collection-properties.html [ URL_http://blog.bdoughan.com/2010/09/jaxb-collection-properties.html ] ): CODESNIPPET_JAVA2 .. details
      • For More Information** URL_http://blog.bdoughan.com/2013/03/binding-to-json-xml-handling-collections.html [ URL_http://blog.bdoughan.com/2013/03/binding-to-json-xml-handling-collections.html ] URL_http://blog.bdoughan.com/2013/06/moxy-is-new-default-json-binding.html [ URL_http://blog.bdoughan.com/2013/06/moxy-is-new-default-json-binding.html ] .. details
      • For More Information** URL_http://blog.bdoughan.com/2013/06/moxy-is-new-default-json-binding.html [ URL_http://blog.bdoughan.com/2013/06/moxy-is-new-default-json-binding.html ] .. details
      • If you are using the URL_http://jersey.java.net/nonav/documentation/latest/jso n.html#json.jaxb.approach.section [JAXB] approach, you can mark fields with CODETERM1 to omit them.. details
      • For More Information** URL_http://blog.bdoughan.com/2010/11/jaxb-and-inheritance-using-substitution.html [ URL_http://blog.bdoughan.com/2010/11/jaxb-and-inheritance-using-substitution.html ] QUESTION 2 Second, is there a way to get rid of "bird", "cat", and "dog"?. details
    7. annotations: 1
      • Related Bug** URL_http://bugs.eclipse.org/372276 [ URL_http://bugs.eclipse.org/372276 ] Recommended Fix** If you add a new mapping in the external mapping file (which is a bit rare since you would have had to explicitly remove the mapping via annotations - URL_http://blog.bdoughan.com/2012/04/jaxb-and-unmapped-properties.html [ URL_http://blog.bdoughan.com/2012/04/jaxb-and-unmapped-properties.html ] ).. details
  • Onlysentiment: 4
    1. general: 4
      • Thanks for quick response I am facing javax.xml.bind.JAXBException: property "eclipselink.media-type" is not supported exception.. details
      • Thanks for this very detailed reply, sorry I should have replied earlier but havent quite understood if it will do what I want.. details
      • What's wrong?. details
      • Sorry this is such a sketchy question, but as I say, I'm just startingout, and terminology is a problem for me at this stage!. details
  • Performance: 1
    1. general: 1
      • Since I am more familiar with Jackson, here are some aspects where I think Jackson has more complete support than Gson (apologies if I miss a Gson feature): Extensive annotation support; including full inheritance, and advanced "mix-in" annotations (associate annotations with a class for cases where you can not directly add them) Streaming (incremental) reading, writing, for ultra-high performance (or memory-limited) use cases; can mix with data binding (bind sub-trees) -- EDIT latest versions of Gson also include streaming reader Tree model (DOM-like access); can convert between various models (tree <-> java object <-> stream) Can use any constructors (or static factory methods), not just default constructor Field and getter/setter access (earlier gson versions only used fields, this may have changed) Out-of-box JAX-RS support Interoperability: can also use JAXB annotations, has support/work-arounds for common packages (joda, ibatis, cglib), JVM languages (groovy, clojure, scala) Ability to force static (declared) type handling for output Support for deserializing polymorphic types (Jackson 1.5) -- can serialize AND deserialize things like List correctly (with additional type information) Integrated support for binary content (base64 to/from JSON Strings) .. details
  • Bug: 27
    1. jackson: 3
      • There is also possibility that JAXB annotation introspector extension (it's a Jackson add-on) could have a bug here.. details
      • I've tried out Jackson but the problem is that its a major rewrite for us since we're so dependent on our JAXB annotations.. details
      • So we find a painful way of checking each field in the car object and if they are null, then set the car as null, so jackson jaxb provider can render it as null.. details
    2. service: 1
      • Could be but I think here the problem is ahead, I am not hitting the service at all.. details
    3. jaxb: 2
      • The exception being thrown is an RI exception (com.sun.xml.internal.bind.v2.runtime package) so EclipseLink MOXy is not being picked up as the JAXB provider.. details
      • MOXy uses the same XJC code as the reference implementation and the JAXB RI also throws an exception if the CODETERM3 is incomplete so I'm not sure what scenario would have excluded it.. details
    4. list: 1
      • Problem is: an "issue" has a "summary" property and a list of fields.. details
    5. general: 12
      • What's the problem?. details
      • It was a problem with jaxb.. details
      • So i then edited Alias.java to add beginDate to propOrder, but this gave this error.. details
      • error.. details
      • Ok, I'm a little embarrassed - adding the dependency does fix the problem and I don't know why I didn't test it before!. details
      • The error: CODESNIPPET_JAVA1 .. details
      • (At the bottom you can find the error message, the WS, the objects & the xsd for one example) Thanks in advance.. details
      • I would like to see if there is an actual bug here.. details
      • What can I do to solve my problem?. details
      • The CODETERM2 is deprecated, is there any other way of solving this problem?. details
      • I get the following error with JSON: CODESNIPPET_JAVA2 .. details
      • Do you guys have any idea what the problem might be?. details
    6. json: 6
      • I think I ended up tracing through it and found that it was a problem in the json provider.. details
      • Is there a way to map JAXB Objects into JSON with some other means, but which will follow the whole JAXB specification so that I have no problems in the future converting from JSON to the JAXB object and visa vera?. details
      • But when I try to convert the JSON back into the JAXB object, it throws an exception connected somehow with the JAXBElement.. details
      • Actually I don't think his problem is really that: if you look carefully at JSON sample he is showing, the multi-object case, there is the bigger issue of content being a String, not JSON.. details
      • @StaxMan his issue is that he wants to force the parsing of JSON into complex objects and he is having issues.. details
      • But for JSON I get the following exception: SEVERE: Mapped exception to response: 500 (Internal Server Error) javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: A message body writer for Java class java.util.Arrays$ArrayList, and Java type java.util.List, and MIME media type application/json was not found I use Jersey 1.6 and, according to the tutorial, JSON format should work with JAXB without any additional programming.. details
    7. android: 1
      • BTW String is also an Object so your Android client (about which you should give some info if that is the problem) should work.. details
    8. types: 1
      • The problem I had with this is, that the types you give to the JSONJAXBContext need to have a no-arg constructor.. details
  • Usability: 108
    1. spring: 2
      • There also must be a way of doing this using PropertyNamingStrategy, the problem I am facing with it is that Spring MVC is handling it somehow differently than serializing something directly with ObjectMapper from JAXB objects.. details
      • Do I dispense with all the custom mapping information and just use JAXB or Spring OXM?. details
    2. request: 1
      • The problem is that when I am trying to use the same for un-marshalling my request it doesnt work.. details
    3. general: 25
      • Yeah., But sometimes I may need to marshall objects which has @Entity annotation too., In that case it will conflict if I try to wrap it in JAXBElement.. details
      • I'm attempting to follow the example located URL_http://stackoverflow.com/questions/14734741/converting-json-to-xml-and- vice-versa-using-jackson-api-and-jaxb-annotation [here] but get an javax.xml.bind.PropertyException.. details
      • Can't you tell me, what's wrong with that approach?. details
      • So i then edited Alias.java to add beginDate to propOrder, but this gave this error.. details
      • The actual model is a little more complex then Ive posted but the additional elements dont seem relevant to the issue.. details
      • Unfortunately it doesn't work.. details
      • If you are using the URL_http://jersey.java.net/nonav/documentation/latest/jso n.html#json.jaxb.approach.section [JAXB] approach, you can mark fields with CODETERM1 to omit them.. details
      • If the above plugin doesn't do exactly what you want (which I think it should, it looks pretty flexible), it shouldn't be too difficult to roll your own modification (I have done this before for adding copy constructors to generated classes).. details
      • I'm concerned that the manner in which i annotate the getter method might be affecting the overall bean as it's passed to the server?. details
      • Thanks for this very detailed reply, sorry I should have replied earlier but havent quite understood if it will do what I want.. details
      • There do appear to be URL_http://sourceforge.net/projects/jaxb-builder/ [Eclipse-tools] that automate this manual drudgery.. details
      • FWIW, this way (of applying to elements) was heavily influenced by JAXB, which has this behavior.. details
      • For More Information** URL_http://blog.bdoughan.com/2010/11/jaxb-and-inheritance-using-substitution.html [ URL_http://blog.bdoughan.com/2010/11/jaxb-and-inheritance-using-substitution.html ] QUESTION 2 Second, is there a way to get rid of "bird", "cat", and "dog"?. details
      • Ok, I'm a little embarrassed - adding the dependency does fix the problem and I don't know why I didn't test it before!. details
      • I think there's some type confusion in getJAXBContext().. details
      • One that we can use internally and one that we will expose externally.. details
      • What can I do to solve my problem?. details
      • In my example I'm using MOXy's default reprentation of CODETERM3 .. details
      • The CODETERM2 is deprecated, is there any other way of solving this problem?. details
      • You can use a Provider to change default behaviour of JSONJAXBContext.. details
      • Is there a better way to decouple these without subjecting yourself to tedious translation/conversion classes?. details
      • At low level, what is needed to make sure that ObjectMapper does NOT use JAXBAnnotationIntrospector, but only default JacksonAnnotationIntrospector.. details
      • For best compatibility 1.6.1 has some further improvements to reduce warnings during initialization (used to complain about missing javax.xml and Joda classes, not any more) .. details
      • Sorry this is such a sketchy question, but as I say, I'm just startingout, and terminology is a problem for me at this stage!. details
      • Ok, i just figured your case was more complex than i though.... details
    4. jackson: 6
      • The default Jersey Jackson provider is configured to use JAXB annotations alongside Jackson ones ;-) The only issue is that the exact configuration of this provider is not documented :-(.. details
      • I followed the instructions URL_http://www.mkyong.com/webservices/jax-rs/json- example-with-jersey-jackson/ [here] which show how to use Jersey and Jackson POJOs(as opposed to JAXB).. details
      • This would not occur with Jackson annotations; and ideally not if you combine Jackson and JAXB annotations (I thought Jersey enabled both).If Jackson annotation processing is also enabled, adding @JsonProperty next to 'getBiz' should also do the trick.. details
      • I've tried out Jackson but the problem is that its a major rewrite for us since we're so dependent on our JAXB annotations.. details
      • So we find a painful way of checking each field in the car object and if they are null, then set the car as null, so jackson jaxb provider can render it as null.. details
      • EDIT (18-Jul-2011): Jackson actually has an extension called " URL_https://github.com/FasterXML/jackson-xml-databind [jackson-xml-databind] " that can read/write XML, similar to JAXB.. details
    5. service: 1
      • Could be but I think here the problem is ahead, I am not hitting the service at all.. details
    6. response: 1
      • Thanks for quick response I am facing javax.xml.bind.JAXBException: property "eclipselink.media-type" is not supported exception.. details
    7. json: 22
      • I think I ended up tracing through it and found that it was a problem in the json provider.. details
      • My classes have jaxb annotations and the system application provider seems to interfere with the jackson json provider.. details
      • Is there a way to map JAXB Objects into JSON with some other means, but which will follow the whole JAXB specification so that I have no problems in the future converting from JSON to the JAXB object and visa vera?. details
      • Mapper transfers it logically to: The JAXB specification** itself does not cover JSON-binding so sometimes implementations are used with libraries like Jettison which converts XML events to/from JSON and problems occur such as collections of size 1 being represented incorrectly.. details
      • Converting JSON to XML and vice versa using Jackson API and JAXB Annotation.. details
      • Actually I don't think his problem is really that: if you look carefully at JSON sample he is showing, the multi-object case, there is the bigger issue of content being a String, not JSON.. details
      • @StaxMan his issue is that he wants to force the parsing of JSON into complex objects and he is having issues.. details
      • Json Response String is {"0":{"0":"Rockey","1":"John"}} I am using Apache CXF Framework with Jettison as the JSON Provider also uses JAXB to wire the data to low bandwidth clients.. details
      • Many libraries incorrectly treat collections of size 1 as JSON objects.. details
      • To solve another problem I have moved from using Jersey to EclipseLink MOXy to generate JSON from a JAXB created object model ( created by Sun JAXB 2.1.12).. details
      • Additional Information as Requested**The json is generated from this MMD schema URL_http://svn.musicbrainz.org/mmd-schema/trunk/brainz-mmd2-jaxb/src/main/resources/musicbrainz_mmd-2.0.xsd [ URL_http://svn.musicbrainz.org/mmd-schema/trunk/brainz-mmd2-jaxb/src/main/resources/musicbrainz_mmd-2.0.xsd ] using JAXB and Jersey , see URL_http://svn.musicbrainz.org/search_server/trunk/servlet/src/main/java/org/musicbrainz/search/servlet/mmd2/ResultsWriter.java [ URL_http://svn.musicbrainz.org/search_server/trunk/servlet/src/main/java/org/musicbrainz/search/servlet/mmd2/ResultsWriter.java ] and URL_http://svn.musicbrainz.org/search_server/trunk/servlet/src/main/java/org/musicbrainz/search/servlet/mmd2/ArtistWriter.java [ URL_http://svn.musicbrainz.org/search_server/trunk/servlet/src/main/java/org/musicbrainz/search/servlet/mmd2/ArtistWriter.java ] The point is that I want to be able to generate Json and XML from one schema with the minimum of fuss, but apparently the Json doesn't look right so Im looking for a way to improve it (I don't really have any experience of json myself) .. details
      • By default, Jersey is using JAXB for the (un)marshalling process, and unfortunately, JAXB JSON processor is not standard (_one-element arrays are ignored, empty arrays are transformed into a one-element empty array..._).. details
      • Adding layers between the two (such as manually handling data binding) can help but is more work.This is not unique to JSON (XML data binding with libs like JAXB has similar challenges), or even data formats: Hibernate and other ORM libs can also add more close-coupling.Another potential challenge is that of losing visibility into what is happening: data binding is often a black box, and when things work, that's great (fewer things to worry about), but when they don't trouble-shooting may be more difficult.. details
      • When I do it, I get error: java.lang.IllegalStateException: Invalid JSON namespace: URL_http://www.w3.org/2001/XMLSchema-instance [ URL_http://www.w3.org/2001 /XMLSchema-instance] Specifically, I have a "Wrapper" class with a "result" field of type SuperClass but it will always be an instance of some sub class ("SubClass" below).. details
      • But for JSON I get the following exception: SEVERE: Mapped exception to response: 500 (Internal Server Error) javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: A message body writer for Java class java.util.Arrays$ArrayList, and Java type java.util.List, and MIME media type application/json was not found I use Jersey 1.6 and, according to the tutorial, JSON format should work with JAXB without any additional programming.. details
      • On the other hand, if you're using the Jersey JSON plugin, you'd have to write a subclass of CODETERM2 , and add JAXB annotations to it - kind of a pain in the ass.. details
      • By default Jersey will use JAXB to process the JSON messages by leveraging the URL_http://jettison.codehaus.org/ [Jettison] library.. details
      • it's really frustrating and I've been fighting with this issue for almost 5 hours now... :( I'd expect JAXB/Jersey to embed my list of downloads in the Project's Json Feed... but unfortunately it's completely missing.. details
      • I assume it comes from a wrong JAXB mapping on SearchResults class but can't figure how to correct it (and it's complicated with the JSON translation to XML).. details
      • I'm a bit new to use JSON format manipulation and not very experimented in JAXB either.What I try to do is building a small client to launch search on Twitter.. details
      • But I'm struggling to understand how to make an employeea member of a team at creation-time by just passing in a Team ID, ratherthan passing in a nested team object in my JSON object.. details
      • Since I am more familiar with Jackson, here are some aspects where I think Jackson has more complete support than Gson (apologies if I miss a Gson feature): Extensive annotation support; including full inheritance, and advanced "mix-in" annotations (associate annotations with a class for cases where you can not directly add them) Streaming (incremental) reading, writing, for ultra-high performance (or memory-limited) use cases; can mix with data binding (bind sub-trees) -- EDIT latest versions of Gson also include streaming reader Tree model (DOM-like access); can convert between various models (tree <-> java object <-> stream) Can use any constructors (or static factory methods), not just default constructor Field and getter/setter access (earlier gson versions only used fields, this may have changed) Out-of-box JAX-RS support Interoperability: can also use JAXB annotations, has support/work-arounds for common packages (joda, ibatis, cglib), JVM languages (groovy, clojure, scala) Ability to force static (declared) type handling for output Support for deserializing polymorphic types (Jackson 1.5) -- can serialize AND deserialize things like List correctly (with additional type information) Integrated support for binary content (base64 to/from JSON Strings) .. details
    8. android: 1
      • BTW String is also an Object so your Android client (about which you should give some info if that is the problem) should work.. details
    9. moxy: 1
      • For More Information** URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html [ URL_http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html ] MOXy as the Default JSON-Binding Provider in Jersey/GlassFish If you are using MOXy as the default JSON-binding provider with Jersey/GlassFish you can leverage the CODETERM11 class as follows: CODESNIPPET_JAVA3 .. details
    10. return: 1
      • But unfortunately in the latest version of the api they have dropped xml support and only return json.. details
    11. string: 1
      • Or do the more common trick of just using a string and don't worry about trying to magically hook everything up in the binding layer.. details
    12. jaxb: 26
      • The exception being thrown is an RI exception (com.sun.xml.internal.bind.v2.runtime package) so EclipseLink MOXy is not being picked up as the JAXB provider.. details
      • +1 - Also since JAXB is the default binding layer for JAX-RS you can just return a JAXB model class and the JAX-RS implementation will leverage JAXB to convert it to XML: URL_http://blog.bdoughan.com/2010/08/creating-restful-web - service-part-35.html.. details
      • Solution to Both Problems Instead of using the default property access, you can use the CODETERM2 annotation to tell JAXB to use field access.. details
      • You can't blame me or my answer for the existence of a disagreement between jaxb and jackson.. details
      • I'm using JAXB 2.2.5 rather than MOXy for class generation, the full source code for schema generation is available from URL_http://svn.musicbrainz.org/mmd - schema/trunk/brainz-mmd2-jaxb/ (note the last checkin of DiscList contains a manually modified propOrder, my fix before I saw yours).. details
      • BTW, if it wasn't clear, the annotations above are standard JAXB which JAX-RS implementations should follow.. details
      • jaxb.properties To specify MOXy as your JAXB provider you need to include a file called CODETERM1 in the same package as your domain model with the following entry (see: URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as- your.html [ URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as - your.html] ): CODESNIPPET_JAVA2 .. details
      • It's a shame that JAXB can't see the setter if it's defined in the super class.. details
      • JAXB (JSR-222) is configuration by exception and only requires annotations where you need to override the default XML representation (Jettison converts XML StAX events to/from JSON).. details
      • jaxb.properties To specify MOXy as your JAXB provider you need to include a file called CODETERM1 in the same package as your domain model with the following entry (see: URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as- your.html [ URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as - your.html] ): CODESNIPPET_JAVA3 .. details
      • DEMO CODE** _**jaxb.properties**_ To specify MOXy as your JAXB provider you need to include a file called CODETERM6 in the same package as your domain model with the following entry (see: URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as- your.html [ URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as - your.html] ): CODESNIPPET_JAVA4 .. details
      • JAXB is for XML, are you confusing it with JAX-RS?. details
      • You can see full mavenized project at URL_http://code.google.com/p/jinahya/sou rce/browse/trunk/com.googlecode.jinahya/stackoverflow/ [ URL_http://code.google.com /p/jinahya/source/browse/trunk/com.googlecode.jinahya/stackoverflow/] JAXB doesn't need the setter if you control to use fields not properties.. details
      • jaxb.properties To specify MOXy as your JAXB provider you need to include a file called CODETERM7 with the followin entry (see URL_http://blog.bdoughan.com/2011/05 /specifying-eclipselink-moxy-as-your.html [ URL_http://blog.bdoughan.com/2011/05 /specifying-eclipselink-moxy-as-your.html] ): CODESNIPPET_JAVA4 .. details
      • jaxb.properties To specify MOXy as your JAXB provider you need to include a file called CODETERM2 in the same package as your domain model with the following entry (see ): CODESNIPPET_JAVA3 .. details
      • For More Information** URL_http://blog.bdoughan.com/search/label/XmlAdapter [ URL_http://blog.bdoughan.com/search/label/XmlAdapter ] URL_http://blog.bdoughan.com/2012/04/binding-to-json-xml-handling-null.html [ URL_http://blog.bdoughan.com/2012/04/binding-to-json-xml-handling-null.html ] I noticed that you had the following comment in your code: // getters and setters with @XmlElement on each attribute Because JAXB (JSR-222) implementations are configuration by exception, you only need to add annotations where you want the XML representation from the default.. details
      • JAXB implementations have default rules for mapping field/property names, but since your document differs from the default each field had to be annotated.. details
      • As a side note, if I add JAXB annotations to my entities (@XmlRootElement on MyFooCollectionWrapper and MyFooDTO) the using the same webResource get call, the client I do not get a message body reader exception, however, the response is marshaled such that MyFooCollectionWrapper looks ok but its collection does not contain a MyFooDTO it contains an XML Document with the proper values in the nodes/attrs - in other words MyFooDTP doesn't get marshaled.. details
      • Below is an example of how the CODETERM1 annotation can be leveraged to map your use case: Foo By default a JAXB implementation will not marshal a null property.. details
      • For More Information** URL_http://blog.bdoughan.com/2012/03/moxy-as-your-jax-rs-json-provider_15.html [MOXy-as-Your-JAX-RS-JSON-Provider---Client-Side] URL_http://blog.bdoughan.com/2012/03/moxy-as-your-jax-rs-json-provider.html [MOXy-as-Your-JAX-RS-JSON-Provider---Server-Side] URL_http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as-your.html [Specifying-EclipseLink-MOXy-as-Your-JAXB-Provider] UPDATE In GlassFish 4 EclipseLink JAXB (MOXy) is the default JSON-binding provider used by Jersey: URL_http://blog.bdoughan.com/2013/06/moxy-is-new-default-json-binding.html [ URL_http://blog.bdoughan.com/2013/06/moxy-is-new-default-json-binding.html ] .. details
      • I found JAXB is too "fat" for my needs.. details
      • Someone suggested a way to solve my problem (in URL_http://stackoverflow.com/questions/5881058/how-to-map-a-bean-structure-to-a -different-schema-with-jax-rs), although it requires using Eclipselink Moxy, which I don't want to introduce (additional dependency and jaxb replacement in whole application).. details
      • It should work as you show; with one possible exception: if you enable JAXB annotations (only), JAXB restrictions mandate that only getter/setter pairs are used to detect properties.So try adding setter for 'biz' and see if that changes it.. details
      • and class that represents "gadget" model (annotated with @XmlRootElement for JAXB processing): CODESNIPPET_JAVA2 .. details
      • Setting the CODETERM1 object to be a JAXB annotated class should solve the problem.. details
      • Ok, no solution found with Jettison (I'm convinced it's a bug) and JAXB mapping for JSON.. details
    13. object: 2
      • But I think, that it's wrong, when object converts to String.. details
      • When you want the shallow fetch, use the default fetch plan and make your returned object transient, e.g.. details
    14. interface: 1
      • However, this always bothered me because it throughly ties your interface and messages with the structure and design of your data model.. details
    15. data: 2
      • Maybe the stack trace holds the solution Update The full project is available online The data model is at URL_http://svn.musicbrainz.org/mmd-schema/trunk/brainz- mmd2-jaxb/ [ URL_http://svn.musicbrainz.org/mmd-schema/trunk/brainz-mmd2-jaxb/ ] Download and run mvn install Then the project that uses this is at URL_http://svn.musicbrainz.org/search_server/trunk/ [ URL_http://svn.musicbrainz.org/search_server/trunk/ ] Download and run mvn package, This contains three subprojects and the problem one is the servlet project, to replicate the issue: cd servlet Edit src/main/resources/oxml.xml changing CODESNIPPET_JAVA8 .. details
      • This may cause data loss because of differences in data model between XML and JSON.. details
    16. class: 3
      • but that is not what I want Update with attempt to use Denises answer** I've ran into a few problems with the proposed solution, first here is the full Alias class I think that would help (note the classes autogenned with JAXB, I came across this before ElipseLink and because my Xml output is okay Im not particulary keen to change this) CODESNIPPET_JAVA4 .. details
      • It works _almost_ fine, however the _first_ request to the server always ends up with the exception: java.lang.NoClassDefFoundError: org/codehaus/jackson/xc/JaxbAnnotationIntrospector For some reason gae/jersey cannot find this class on the initial request.. details
      • If I make my Wrapper class have its "result" field defined as subclass type "SubClass" it works OK, but when it is of type "SuperClass" but the instance of of SubClass I get the error.. details
    17. types: 1
      • The problem I had with this is, that the types you give to the JSONJAXBContext need to have a no-arg constructor.. details
    18. package: 1
      • mvn package src/test/java/org/musicbrainz/search/servlet/FindWorkTest will now fail ontestOutputAsJsonNew() and testOutputAsJsonNewPretty() Further Update**Blaise worked out the problem the example doesn't show (and I wasn't aware) that you can actually have multiple relationList elements, i.e the Xml could be CODESNIPPET_JAVA10 .. details
    19. required: 1
      • But the actual requirement is a more complex transformation, Im not sure how to explain it in the correct terminology but here is an example of the required output.. details
    20. list: 3
      • Oh I see, the problem is you can have more than one relation-list element (with a different type attribute), so instead of there being a RelationList element, there isd a list of RelationList elements URL_http://svn.musicbrainz.org /mmd-schema/trunk/brainz- mmd2-jaxb/src/main/java/org/musicbrainz/mmd2/Work.java right well least I can see the problem now.. details
      • I suspect this has something to do with the fact that CODETERM6 is a list rather than a single value.. details
      • Problem is: an "issue" has a "summary" property and a list of fields.. details
    21. element: 2
      • Unfortunately I cannot use the @XmlElement option because beginDate is an attribute not an element and already has a @XmlAttribute annotation, and this does not seem to support nillable.. details
      • The CODETERM4 element is a complex type with simple content (see: URL_http://blog.bdoughan.com/2011/06/jaxb-and-complex-types-with-simple.html [ URL_http://blog.bdoughan.com/2011/06/jaxb-and-complex-types-with-simple.html ] ).. details
    22. jersey: 1
      • Works nicely with Jersey, and I am use it myself (current Jersey version does not bundle full Pojo data binding by default, but will in near future) I would actually not use any of xml libs to produce "json": XStream and JAXB/Jettison can produce kind of JSON, but it uses ugly conventions that are rather non-intuitive.. details
    23. root: 2
      • By default CODETERM9 is configured not to include the root element.. details
      • Default setting is false, meaning root value is not wrapped.. details
    24. versioning: 1
      • Our use case was more complex with DTOs, JPA entities, versioning etc.. details