CXF's JsonProvider not displaying subclass element

Solution Verified - Updated -

Issue

  • We are using default JSONProvider from JBoss Fuse 6.2.1 for our rest API to construct our the JSON output. However, the output format is unexpected.
    • It automatically convert a String to int (e.g. Expected: {"terminal":"1"}. The actual output: {"terminal":1})
    • It simply output the parameters from base class, and ignore the content from subclass. E.g.
class Base {
    String terminal;
    //get & set...
}
class Sub extends Base {
    String otherInfo;
    //get & set...
}

Base b = new Sub();
b.setTerminal("1");
(Sub(b)).setOtherInfo("abc");

The expected output will be {"terminal":"1", "otherInfo":"abc"}.
While the actual output is {"terminal":1}.

  • The configuration in Blueprint file is as following:

    <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
    <property name="dropRootElement" value="true"></property>
    <property name="supportUnwrapped" value="true"></property>
    <property name="ignoreNamespaces" value="true"></property>
    </bean>
    

Environment

  • Red Hat JBoss Fuse
    • 6.2.1
    • 6.3.x
  • Apache CXF

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