title: Serializing Object to YAML in Java using snakeyaml Library
body: <p>I do not have much experience with Serialization. While trying to serialize a simple object of the class below i get this <code>No JavaBean properties found exception</code> from YAML library.  </p>
  
  <p>Here is the class:  </p>
  
  <pre><code>public class MyClass {
      String value;
      public MyClass(String args) {
          value = args;
      }
  
      public String getValue(){
          return value;
      }
  }
  </code></pre>
  
  <p>And here is how i am serializing using SnakeYAMAL:  </p>
  
  <pre><code>import java.util.HashMap;
  import java.util.Map;
  
  import org.yaml.snakeyaml.Yaml;
  
  
  public class Test {
  
      public static void main(String[] args) {
  
          MyClass obj = new MyClass("this is my data");
  
          Map&lt;String, Object&gt; data = new HashMap&lt;String, Object&gt;();
          data.put("MyClass", obj);
          Yaml yaml = new Yaml();
          String output = yaml.dump(data);
          System.out.println(output);
      }
  
  }
  </code></pre>
  
  <p>and upon executing, this exception is thrown:  </p>
  
  <pre><code>Exception in thread "main" org.yaml.snakeyaml.error.YAMLException: No JavaBean properties found in MyClass
      at org.yaml.snakeyaml.introspector.PropertyUtils.getProperties(PropertyUtils.java:112) ...
  </code></pre>
  
  <p>Can you tell me what is it that i am missing in doing this, or how should i do it properly?</p>
  
  <p>EDIT:  </p>
  
  <pre><code>public class MyClass {
      String value;
      public MyClass() {}
  
      public String setValue(String value){
          this.value = value;
      }
  
      public String getValue(){
          return value;
      }
  }
  </code></pre>
  
  <p>and if i set the value before serializing it, it somehow works.
  Do you think it is proper solution or not a recommended approach?</p>