title: Jackson JSON serialization, recursion avoidance by level defining
body: <p>I use Jackson library for serialization of my pojo objects into <code>JSON</code> representation. 
  For example I have class A and class B:</p>
  
  <pre><code>class A {
    private int id;
    private B b;
  
    constructors...
    getters and setters
  }
  
  class B {
    private int ind;
    private A a;
  
    constructors...
    getters and setters
  }
  </code></pre>
  
  <p>If I want to serialize object from class A there is certain possibility to get recursion while it is serialized. I know i can stop it by using <code>@JsonIgnore</code>.</p>
  
  <p><strong>Is it possible to limit the serialization by depth-level ?</strong></p>
  
  <p>For example, if the level is 2, the serialization will go this way:</p>
  
  <ul>
  <li>serialize a, level = 0 (0 &lt; 2 ok) - > serialize </li>
  <li>serialize a.b, level =1
  (1 &lt; 2 ok) -> serialize  </li>
  <li>serialize a.b.a, level = 2 (2 &lt; 2 not true) ->
  stop</li>
  </ul>
  
  <p>Thanks in advance.</p>