jaxb - How do I get Json generated by MOXy to understand when model are numbers -


To solve another problem I have gone using JASAB to generate Jasonon from the object model created by (Created by Sun JAXB 2.1. 12). I've noticed a difference that the numeric attribute in the object model is defined as

XxLSchemaType (name = "nonNegativeInteger"); BigInteger calculation;

jersey

  converts to "count": 1,  

but MOXy returns

 

How can I get it to realize a numerical field and not to quote it?

UPDATE

Eclipse link 2.4.1 and A fix has been checked in streams 2.5.0. July 13, 2012 > Marshall numeric types to JSON without quotation marks. In this case the presence of @ XmlSchemaType annotation is causing a problem. This is a bug and you can use the following links to track our progress on this issue:

The external mapping document of Maxie can be used to override mapping at the area / property level.

P>
  & lt ;? XML version = "1.0"? & Gt; & Lt; Xml-binding xmlns = "http://www.eclipse.org/eclipselink/xsds/persistence/oxm" package-name = "forum 11448966" & gt; & Lt; Java-type & gt; & Lt; Java-type name = "root" & gt; & Lt; Java-Properties & gt; & Lt; Xml-element java-attribute = "count" / & gt; & Lt; / Java-Properties & gt; & Lt; / Java type & gt; & Lt; / Java-type & gt; & Lt; / XML-binding & gt;  

Route

  Package forums 11448966; Import java.math.BigInteger; Import javax.xml.bind.annotation *; @XmlAccessorType (XmlAccessType.FIELD) public square root {@XmlSchemaType (name = "nonNegativeInteger") BigInteger calculation; }  

jaxb.properties

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

Demo

Package forums 11448966; Import java.math.BigInteger; Import java.util. *; Import javax.xml.bind. *; Import org.eclipse.persistence.jaxb.JAXBContextProperties; Public square demo {public static zero main (string [] args) exception {map & lt; String, Object & gt; Properties = New Hashmop & lt; String, Object & gt; (3); Properties.put (JAXBContextProperties.OXM_METADATA_SOURCE, "Forum 11448966 / oxm.xml"); Properties.put (JAXBContextProperties.MEDIA_TYPE, "App / Jason"); Properties.put (JAXBContextProperties.JSON_INCLUDE_ROOT, incorrect); JAXBContext jc = JAXBContext.newInstance (New Classroom [] {Root.class}, Properties); Root root = new root (); Root.count = BigInteger.TEN; Marshall Marshaller = J.C. Caye Marshaller (); Marshaller.setProperty (Marshaler. JAXB_FORMATTED_OUTPUT, true); Marshaller Martial (root, system out); }}

Output

  {"count": 10}  

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -