private void parseNext(JsonReader in, HashMap<String, Object> objMap) throws IOException {
    JsonToken token = in.peek();

    String lastName = "";
    if (token == JsonToken.NAME) {
      lastName = in.nextName();
      token = in.peek();
    }

    switch (token) {
      case BEGIN_ARRAY:
        parseArray(in, objMap, lastName);
        break;
      case BEGIN_OBJECT:
        parseObject(in, objMap, lastName);
        break;
      case STRING:
        objMap.put(lastName, in.nextString());
        break;
      case NUMBER:
        objMap.put(lastName, in.nextDouble());
        break;
      case BOOLEAN:
        objMap.put(lastName, in.nextBoolean());
        break;
      default:
        throw new IOException("Unexpected JSON token encountered");
    }

    collapseMap(objMap);
  }
private void parseNext ( JsonReader in , HashMap < String , Object > objMap ) throws IOException { JsonToken token = in . peek ( ) ; String lastName = "" ; if ( token == JsonToken . NAME ) { lastName = in . nextName ( ) ; token = in . peek ( ) ; } switch ( token ) { case BEGIN_ARRAY : parseArray ( in , objMap , lastName ) ; break ; case BEGIN_OBJECT : parseObject ( in , objMap , lastName ) ; break ; case STRING : objMap . put ( lastName , in . nextString ( ) ) ; break ; case NUMBER : objMap . put ( lastName , in . nextDouble ( ) ) ; break ; case BOOLEAN : objMap . put ( lastName , in . nextBoolean ( ) ) ; break ; default : throw new IOException ( "Unexpected JSON token encountered" ) ; } collapseMap ( objMap ) ; }
Checks the next {@link JsonToken} to decide the next appropriate parsing method.

@param in {@link JsonReader} object used for parsing
@param objMap Map used to build the structure for the resulting {@link QueryAggregation} object
@throws IOException signals that there has been an IO exception