<dependency>
<groupId>io.protostuff</groupId>
<artifactId>protostuff-yaml</artifactId>
<version>1.0.8</version>
</dependency>
public class Person {
private String name;
private int age;
// getters and setters
// constructor
}
import io.protostuff.runtime.DefaultIdStrategy;
import io.protostuff.runtime.RuntimeSchema;
import io.protostuff.Schema;
import io.protostuff.ProtostuffIOUtil;
import io.protostuff.YamlIOUtil;
// ...
Schema<Person> schema = RuntimeSchema.getSchema(Person.class);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
YamlIOUtil.writeTo(outputStream, person, schema);
String serializedYaml = outputStream.toString("UTF-8");
System.out.println(serializedYaml);
yaml
age: 25