title: How to read JSON object from JsonToken.START_OBJECT to JsonToken.END_OBJECT using jackson JsonParser
body: <p>I am using Jackson JsonParser to parse the json tokens one by one. The idea is to create a list of parameters that are passed to the HTTPServletRequest object as a JSON Post Body. The Body may contain simple types like integer, double, true, false values in addition to array of simple and object values plus objects themselves. The aim to create list of parameters is that I pass the method name and the class name in the URL itself and so I know which method to call. The sequence of parameters in the request body exactly matches the expected arguments by that method.
  For doing this, I am able to add simple objects and simple types in the parameter list. However, the parameters might contain an array of remote objects as well.</p>
  <p>In that case it looks like this:</p>
  <pre><code>{
      &quot;remoteClass&quot;: &quot;com.example.Component&quot;,
      &quot;child&quot;: [
          {
              &quot;remoteClass&quot;: &quot;com.example.Component&quot;,
              &quot;field&quot;: &quot;ID&quot;,
              &quot;fieldType&quot;: null,
              &quot;operator&quot;: &quot;=&quot;,
              &quot;value&quot;: 1710
          },
          {
              &quot;remoteClass&quot;: &quot;com.example.Component&quot;,
              &quot;field&quot;: &quot;ID&quot;,
              &quot;fieldType&quot;: null,
              &quot;operator&quot;: &quot;=&quot;,
              &quot;value&quot;: 1711
          },
          {
              &quot;remoteClass&quot;: &quot;com.example.Component&quot;,
              &quot;field&quot;: &quot;Time&quot;,
              &quot;fieldType&quot;: null,
              &quot;operator&quot;: &quot;&gt;=&quot;,
              &quot;value&quot;: &quot;2013-04-04T18:30:00.000Z&quot;
          },
          {
              &quot;remoteClass&quot;: &quot;com.example.Component&quot;,
              &quot;field&quot;: &quot;Time&quot;,
              &quot;fieldType&quot;: null,
              &quot;operator&quot;: &quot;&lt;=&quot;,
              &quot;value&quot;: &quot;2013-04-25T18:29:59.999Z&quot;
          }
      ]
  }
  </code></pre>
  <p>My Component class representation is like:</p>
  <pre><code>public class Component implements Serializable
  {
  private static final long serialVersionUID = 1L;
  
  public Component[] child;
  
  // Field name
  public String field;
  
  // Field type
  public String fieldType;
  
  // Operator
  public String operator;
  
  // Value
  public Object value;
  
  }
  </code></pre>
  <p>Since, I am using JsonParser and parsing token one by one. Whenever, I receive any token which starts with JsonToken.START_OBJECT, I want to directly convert the object to the class specified by remoteClass field, instead of parsing further for each token and creating map or json manually. Since, the class is known before hand, I can use jackson to automatically give me the object. However, I want to know if once JsonParser gives me the JsonToken.START_OBJECT token, how can I read the whole JSON till JsonToken.END_OBJECT and convert it to the relevant type specified, so that when the Jsonparser fetches the next token, it fetches after the object encountered has been completed converted and added in my list of parameters.</p>
  <p>Any help is highly appreciated.</p>