title: I am using JsonReader in Android, and i need a value inside the current object before parsing an inner object
body: <p>My JSON object looks something like this:</p>
  
  <pre><code>{
      id: 1
      object:
          {
              object_id:1
              key_for_1: "value for object type 1"
          }
      type: "object_type_1"
   }
  
  {
      id: 2
      object:
          {
              object_id:5
              key_for_23: "value for object type 23"
          }
      type: "object_type_23"
   }
  </code></pre>
  
  <p>So, basically i need "type" before i can parse object. Is there a way to ensure that I can grab the value for "type" before i grab "object"?</p>
  
  <p>JsonReader is has pretty much the same methods as GSON. Here is how I am parsing it:</p>
  
  <pre><code>public CustomObject(JsonReader reader) throws IOException {
      reader.beginObject();
      while (reader.hasNext()) {
  
          String name = reader.nextName();
  
          if (name.equals("id")) {
              clId = reader.nextDouble();
          } 
  
          else if (name.equals("object")) {
              innerObject = new InnerObject(reader);
          }
  
          else if (name.equals("type")) {
              type = reader.nextString();
          }
      }
  
      reader.endObject();
  }
  </code></pre>
  
  <p>I don't want to just use a string builder because the actual JSON object I get back is HUGE (the one above is just a sample). I tried StringBuilder first and I am seeing quite a few out of memory problems which is why I wanted to move to JsonReader. </p>
  
  <p>Any help would be awesome. Thanks</p>