moxy

Represent null value as empty element in xml jaxb

久未见 提交于 2019-11-26 18:16:36
问题 I need to display null value as empty element in jaxb. I am using moxy implementation of jaxb. I found this option @XmlNullPolicy(emptyNodeRepresentsNull = true, nullRepresentationForXml = XmlMarshalNullRepresentation.EMPTY_NODE) Is there any similar extension that can be applied at Class level (for all elements defined in it) 回答1: I would strongly recommend representing null with either the absence of the node or with the xsi:nil="true" attribute. This works best with schema validation (i.e.

How to return a JSON object from a HashMap with Moxy and Jersey

不问归期 提交于 2019-11-26 11:33:46
问题 I am using Jersey 2.17 with Moxy and I have functions like : @Produces(APPLICATION_JSON) @Restricted public List<User> getFriends( @PathParam(\"user\") String user ) { return userDAO.getFriends(user); } User.preferences is a HashMap . It works fine for almost all Objects except for a HashMap which gets translated into: \"preferences\":{\"entry\":[{\"key\":{\"type\":\"string\",\"value\":\"language\"},\"value\":{\"type\":\"string\",\"value\":\"en\"}},{\"key\":{\"type\":\"string\",\"value\":\