Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 19. JSON Support via Jackson
Apart from the Jettison JAXB adapter for JSON, RESTEasy also supports integration with the Jackson project. Many users find Jackson's output format more intuitive than the format provided by either BadgerFish or Jettison.
Jackson is available from http://jackson.codehaus.org. It lets you easily marshal Java objects to and from JSON. Jackson has a JavaBean-based model and JAXB-like APIs. RESTEasy integrates with the JavaBean model as described in the Jackson Tutorial.
To include Jackson in your project, add the following Maven dependency to your build:
RESTEasy expands the JAX-RS integration built into Jackson in several ways. The first expansion provided support for
application/*+json. Previously, Jackson accepted only application/json and text/json as valid media types. application/*+json support lets you marshal your JSON-based media types with Jackson. For example:
Using RESTEasy JAXB providers alongside Jackson is also problematic. Rather than use Jackson to output your JSON, you can use Jettison and JAXB. To do so, you must either not install the Jackson provider, or use the
@org.jboss.resteasy.annotations.providers.NoJackson annotation on your JAXB annotated classes, like so:
If you cannot annotate the JAXB class with
@NoJackson, tehn you can annotate a method parameter instead:
19.1. Possible Conflict With JAXB Provider Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
If your Jackson classes are annotated with JAXB annotations and the
resteasy-jaxb-provider is on your classpath, you can trigger the Jettison JAXB marshalling code. To disable the JAXB JSON Marshaller, annotate your classes with @org.jboss.resteasy.annotations.providers.jaxb.IgnoreMediaTypes("application/*+json").