Class YamlSerializer

java.lang.Object
org.rapidcontext.core.data.YamlSerializer

public class YamlSerializer extends Object
A data serializer and unserializer for the YAML format. The object mapping to YAML is not exact, and may omit serialization of data in some cases. The following basic requirements must be met in order to serialize an object:
  • No circular references are permitted.
  • String, Integer, Boolean, Date, Array and Dict values are supported.
Version:
1.0
  • Method Details

    • serialize

      public static void serialize(Object obj, OutputStream os) throws IOException
      Serializes an object into a YAML representation.
      Parameters:
      obj - the object to convert, or null
      os - the output stream to write to
      Throws:
      IOException - if the data couldn't be serialized
    • serialize

      public static String serialize(Object obj)
      Serializes an object into a YAML representation.
      Parameters:
      obj - the object to serialize, or null
      Returns:
      a YAML file representation
    • unserialize

      public static Object unserialize(InputStream is) throws IOException
      Unserializes an object from a YAML representation.
      Parameters:
      is - the input stream to load
      Returns:
      the object read
      Throws:
      IOException - if an error occurred while reading