Skip to content

Latest commit

 

History

History
53 lines (37 loc) · 2.36 KB

README.md

File metadata and controls

53 lines (37 loc) · 2.36 KB

Overview

This project contains Jackson extension component for reading and writing YAML encoded data. Since version 3.0, which is being developed in this branch, SnakeYAML Engine library will be used for low-level YAML parsing. In current released versions 2.* SnakeYAML library is used. See separate branches 2.9 and 2.10 for sources. This project adds necessary abstractions on top to make things work with other Jackson functionality.

Project is licensed under Apache License 2.0.

Status

Build Status Maven Central Javadoc

Module has been production ready since version 2.5.

Maven dependency

To use this extension on Maven-based projects, use following dependency:

<dependency>
  <groupId>com.fasterxml.jackson.dataformat</groupId>
  <artifactId>jackson-dataformat-yaml</artifactId>
  <version>2.9.2</version>
</dependency>

Usage

Simple usage

Usage is as with basic JsonFactory; most commonly you will just construct a standard ObjectMapper with com.fasterxml.jackson.dataformat.yaml.YAMLFactory, like so:

ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
User user = mapper.readValue(yamlSource, User.class);

but you can also just use underlying YAMLFactory and parser it produces, for event-based processing:

YAMLFactory factory = new YAMLFactory();
YAMLParser parser = factory.createParser(yamlString);
while (parser.nextToken() != null) {
  // do something!
}

Documentation

  • Wiki contains links to Javadocs, external documentation