Skip to content

snakeyaml/snakeyaml-engine

Repository files navigation

The art of simplicity is a puzzle of complexity.

Overview

YAML is a data serialization format designed for human readability and interaction with scripting languages.

SnakeYAML Engine is a YAML 1.2 processor for the Java Virtual Machine version 8 and higher.

Latest release

API

  • The Engine will parse/emit basic Java structures (String, List, Map<String, Boolean>). JavaBeans or any other custom instances are explicitly out of scope.
  • Since the custom instances are not supported, parsing any YAML document is safe - the YAML input stream is not able to instruct the Engine to call arbitrary Java constructors (unless it is explicitly enabled)

SnakeYAML Engine features

  • a complete YAML 1.2 processor. In particular, SnakeYAML can parse (almost) all examples from the specification.
  • Integrated tests from YAML Test Suite - Comprehensive Test Suite for YAML
  • Unicode support including UTF-8/UTF-16/UTF-32 input/output.
  • Low-level API for serializing and deserializing native Java objects.
  • All the Schemas are supported. (A good introduction to schemas)
  • Relatively sensible error messages (can be switched off to improve performance).
  • When you plan to feed the parser with untrusted data please study the settings which allow to restrict incoming data.

Info

Contribute

JMH microbenchmarks

To execute the JMH microbenchmarks locally via Maven:

./mvnw jmh:benchmark

This will produce console results such as the following, as well as a ./jmh-result.json that can be visualized via https://jmh.morethan.io/ .

Benchmark                    (entries)  Mode  Cnt    Score     Error  Units
EmitterBenchmark.emitScalar        N/A  avgt    3    0.299 ±   0.047  us/op
ParseBenchmark.load               1000  avgt    3    1.388 ±   0.103  ms/op
ParseBenchmark.load             100000  avgt    3  258.281 ± 367.009  ms/op
ParseBenchmark.parse              1000  avgt    3    0.886 ±   0.163  ms/op
ParseBenchmark.parse            100000  avgt    3   94.930 ±   3.995  ms/op