0 Replies Latest reply on Oct 3, 2014 6:25 PM by firepod

    Wildfly 8.1 RESTful Services...Which API for Marshaling JSON?

    firepod Newbie

      For completely new development that will deploy on Wilfly 8.1 and later, what is the recommend API to build RESTful web services that only produce and consumer JSON? If it's JAX-RS (via annotations), what's the recommended way to marshal objects as JSON?


      I see many different tutorials and documentation that talk about varying versions of Wildfly, JBoss and Java EE, but no clear recommendation as to what to use or place to start now that v8.1 is fully JavaEE 7 certified.


      I know that Wildfly 8 includes RESTEasy 3.0.9 and in the RESTEasy 3.0.9 documentation, it appears that JAX-RS 2 is the prevailing method, however it's unclear in the documentation what the recommendation is for how to define the JSON response. It references that any JAXB annotated object will be rendered as JSON, but two points on this:


      1. The JAXB annotations are extremely XML centric, leading one to conclude that their is a JSON way instead. I say XML centric because for example, it references using @XmlRootElement annotation for the root node.. and @XmlElement for fields. .... perhaps this is just JavaEE's baggage from it's long history of rich support for XML based APIs.. It just feels that there should be a cleaner, simpler JSON way.
      2. The key examples in the RESTEasy documentation don't work. In specific, in section 19.4 utilizing the first JAXB class example, according to the documentation "The default Jettison Mapped Convention would return JSON that looked like this:"

      { "book" :

            {

               "@title":"EJB 3.0",

               "author":"Bill Burke",

               "ISBN":596529260

             }

      }

      However, it in fact generates the following:

      {

          "author": "Bill Burke",

          "title": "EJB 3.0",

          "isbn": "596529260"

      }

      And it doesn't provide any instructions on how to get the root "book" node to work, which of course I need.

       

      Thanks.