title: How to recursively serialize an object using reflection?
body: <p>I want to navigate to the N-th level of an object, and serialize it's properties in String format.
  For Example:</p>
  
  <pre><code>class Animal {
     public String name;
     public int weight;
     public Animal friend;
     public Set&lt;Animal&gt; children = new HashSet&lt;Animal&gt;() ;
  }
  </code></pre>
  
  <p>should be serialized like this:</p>
  
  <pre><code>{name:"Monkey",
   weight:200,
   friend:{name:"Monkey Friend",weight:300 ,children:{...if has children}},
   children:{name:"MonkeyChild1",weight:100,children:{... recursively nested}}
  }
  </code></pre>
  
  <p>And you may probably notice that it is similar to serializing an object to json. I know there're many libs(Gson,Jackson...) can do this, can you give me some instructive ideas on how to write this by myself?</p>