Can I get MOXy to not output an element when generating json?

An instance of my JAXB Object model contains an element that I want output when I generate Xml for the instance but not when I generate json

i.e I want



"release-group" : {
         "title" : "fred",

but have

"release-group" : {
         "type" : "Album",
         "title" : "fred"

Can I do this using the oxml.xml mapping file

This answer shows how I can do it for attributes using the transient keyword, Can I get MOXy to not output an attribute when generating json? but I cannot get that to work for an element.


Sorry problem solved, a bit of confusion on my part.

The example I gave above didn't actually match the true situation accurately, type was actually output as an attribute for Xml, but use of transient didnt work because it had been renamed in the JAXB

@XmlAttribute(name = "target-type", required = true)
@XmlSchemaType(name = "anyURI")
protected String targetType;

So adding

 <java-type name="ReleaseGroup">
                <xml-transient java-attribute="targetType"/>

worked, previously I was incorrectly doing

 <java-type name="ReleaseGroup">
                <xml-transient java-attribute="target-type"/>

Need Your Help

Good solution for Payment Processing in Django

python django payment-processing django-paypal

I am trying to pick a payment processing solution for my Django app and would like to know of some good general solutions.