Este contenido no está disponible en el idioma seleccionado.

Chapter 21. YAML Provider


Since Beta 6, RESTEasy includes built-in support for YAML with the JYAML library. To enable YAML support, add the jyaml-1.3.jar to RESTEasy's classpath.
The JYAML JAR can be downloaded from SourceForge.
If you use Maven, the JYAML JAR is available through the main repositories, and included with the following dependency:
 <dependency>
<groupId>org.jyaml</groupId>
<artifactId>jyaml</artifactId>
<version>1.3</version>
 </dependency>
Copy to Clipboard Toggle word wrap
When starting up RESTEasy, watch the logs for a line stating that the YamlProvider has been added — this indicates that RESTEasy has located the JYAML JAR:
2877 Main INFO org.jboss.resteasy.plugins.providers.RegisterBuiltin - Adding YamlProvider
Copy to Clipboard Toggle word wrap
The YAML provider recognises three MIME types:
  • text/x-yaml
  • text/yaml
  • application/x-yaml
You can use YAML in a resource method like so:
 import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;

 @Path("/yaml")
 public class YamlResource
 {

@GET
@Produces("text/x-yaml")
public MyObject getMyObject() {
   return createMyObject();
}
...
 }
Copy to Clipboard Toggle word wrap
Volver arriba
Red Hat logoGithubredditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

Theme

© 2025 Red Hat