JSON Marshaller does not respect JAXB annotations

Solution Verified - Updated -

Issue

When using the JSON Marshaller to construct a payload to create a BPM process, then the JAXB annotations are not respected.

Using this method:

public String createBPM(ProcessorData data) {

    HashSet<Class<?>> classes = new HashSet<Class<?>>();
    classes.add(ProcessorData.class);

    Marshaller marshaller = MarshallerFactory.getMarshaller(classes, MarshallingFormat.JSON, getClass().getClassLoader());

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("inProcessorData", data);

    return marshaller.marshall(map);
}

Produces a payload where JAXB annotations inside ProcessorData are simply not present. For example, if JAXB annotation is overriding an attribute name, then this attribute name won't be changed in the final JSON payload.

Environment

  • Red Hat JBoss BPM Suite
    • 6.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content