Class JSUtilities.YAML

java.lang.Object
org.bzdev.util.JSUtilities.JSON
org.bzdev.util.JSUtilities.YAML
Enclosing class:
JSUtilities

public static class JSUtilities.YAML extends JSUtilities.JSON
Class for parsing YAML streams. This class, like the corresponding JSON class, provides static methods for parsing a YAML stream that produces a single object.

Unlike JSON, YAML allows a sequence of objects to be read from a single stream, with objects' YAML representation separated by a line starting with "---" (such streams must start with the line "%YAML VERSION" followed by some optional tag definitions, and the sequence "---" at the start of a line). This class does not support this particular case: instead use JSUtilities.YAML.Parser to handle multiple independent objects

It is possible to automatically convert strings to various data types. A few standard conversions are build in. These can be extended by creating instances of JSUtilities.YAML.TagSpec, and using that in a suitable constructor as described below.

The YAML parser will throw an exception if the input stream contains tabs (the YAML specification does not allow tabs). If one needs to handle files with tabs, the class DetabReader can be used to turn those tabs into the appropriate number of spaces.

See Also: