moxy

EclipseLink MOXy JSON Serialization

寵の児 提交于 2019-11-29 09:45:47
I have got a sample class: class Zoo { public Collection<? extends Animal> animals; } When serialized with MOXy, I am getting: { "bird": [ { "name": "bird-1", "wingSpan": "6 feets", "preferredFood": "food-1" } ], "cat": [ { "name": "cat-1", "favoriteToy": "toy-1" } ], "dog": [ { "name": "dog-1", "breed": "bread-1", "leashColor": "black" } ] } Why is it using array indicators "[]", while bird, cat, and dog are not arrays? Second, is there a way to get rid of "bird", "cat", and "dog"? In other words, I am trying to get to: { { "name": "bird-1", "wingSpan": "6 feets", "preferredFood": "food-1" }

What is the moxy equivalent to Jackson's JsonAnySetter?

╄→尐↘猪︶ㄣ 提交于 2019-11-29 02:39:22
I'm attempting to move to Jersey 2.0. Which is giving me pains with Jackson, and the docs recommend using Moxy. I got Moxy working for get and post calls where everything matches nicely however I have a need to deal with possible unknown elements. // Handle unknown deserialization parameters @JsonAnySetter protected void handleUnknown(String key, Object value) { if (unknownParameters == null) { unknownParameters = new HashMap<>(); } unknownParameters.put(key, value); } This worked well with prior to changing to jersey 2.0 and even though it doesn't cause any problems when I leave it in it

Use Moxy as default JAXB Implementation

余生颓废 提交于 2019-11-28 20:53:33
In order to use Moxy as JAXB Implementation, one has to add a file called jaxb.properties in the folder with the domain classes of the application and include the following line javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory Is it possible to make moxy the default for the project ? In case I have many different folders with annotated domain classes in which folder should I put this file? Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB (JSR-222) expert group. MOXy is already the default JAXB implementation in WebLogic 12.1.1: http://blog

JAXB unmarshalling multiple XML elements into single class

我只是一个虾纸丫 提交于 2019-11-28 10:14:46
I have the following XML structure, which is modelling a single concept across multiple XML elements. This format is not in my control. <Output> <Wrapper> <Channel> <id>1</id> <type>x</type> </Channel> <Channel> <id>2</id> <type>y</type> </Channel> <ChannelName> <id>1</id> <name>Channel name</name> </ChannelName> <ChannelName> <id>2</id> <name>Another channel name</name> </ChannelName> </Wrapper> </Output> I want to model this in a database that I do have control over and can have a more simple Channel table with id , type and name fields. Therefore I would like to unmarshal into a single List

How to use Moxy XPath annotated beans in web services?

喜欢而已 提交于 2019-11-28 09:24:38
问题 I have a bean @XmlRootElement(name = "alpha") public class MyBean { private String thetaValue; @XmlPath("beta/theta/text()") public String getThetaValue() { return this.thetaValue; } public void setThetaValue(String thetaValue) { this.thetaValue = thetaValue; } } This is annotated using eclipselink moxy jaxb. I want to use the same bean and Xpath to host a web service. How do I do this? the web service will be hosted on tomcat 6 or 7 回答1: There isn't a standards based integration point

(moxy) jaxb marshaling and hibernate proxy objects

独自空忆成欢 提交于 2019-11-28 07:52:20
问题 In the last couple of days I have tried to make support for XML marshalling/unmarshalling of a Hibernate model, using MOXy JAXB. Trying to do this, I have run into a problem with hibernates proxy objects. Consider something like: public class User { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "address") public Address getAddress() { return address; } } public abstract class Address { // Something } public class CoolAddress extends Address { public String getSomething() { return

Jersey 2.0 equivalent to POJOMappingFeature

风格不统一 提交于 2019-11-28 06:15:42
I have some experience using Jersey < 2.0. Now I am trying to build a war application to provide a JSON Webservice API. I am now struggling for a considerable amount of time trying to configure Moxy and it seams to be way more complicated than what was adding <init-param> <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name> <param-value>true</param-value> </init-param> to your web.xml back in Jersey < 2.0. Is there some possibility to just say "please add json support"? Currently I just get a lot of Internal Server Error errors without any log entries on the server and just

Configuring CXF with Spring to use MOXY for XML marshalling/unmarshalling

左心房为你撑大大i 提交于 2019-11-28 05:31:58
问题 I have a Java server application that uses CXF to provide SOAP and REST web services. Currently it uses the reference implementation of JAX-B for XML marshalling/unmarshalling, but I have configured it to replace Jettison with Jackson for JSON marshalling/unmarshalling. I use Spring for DI and application context configuration. The REST web service configuration snippets looks as follows: web.xml <servlet> <display-name>Myapp REST Services</display-name> <servlet-name>MyappWebServices<

Customizing JSON marhsalling with GlassFish v4

不羁岁月 提交于 2019-11-28 04:18:19
问题 We've got a JAX-RS application that runs on Apache TomEE. We slightly customize the default Jettison provider to better adhere to JSON conventions used by JavaScript frontend. TomEE allows to do it via its resources.xml file: <resources> <Service id="jettison" class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider"> serializeAsArray = true dropRootElement = false arrayKeys = members,roles supportUnwrapped = true writeXsiType = false </Service> </resources> Now we are migrating to

Remove “type” from JSON output jersey moxy

允我心安 提交于 2019-11-28 03:17:45
问题 How to remove the type from the JSON output that I have. I have a class/bean that contains output of a REST service.I'm using jersey-media-moxy to do the conversion. The service @Resource public interface MyBeanResource { @GET @Path("/example") @Produces( MediaType.APPLICATION_JSON ) public Bean getBean(); } The Bean @XmlRootElement class Bean { String a; } I want to add some functionality (for initializing the bean using the constructor) class BeanImpl extends Bean { BeanImpl(OtherClass c) {