private Map<String, Integer> readHeaderFields(JsonParser jp)
     throws JsonParseException, IOException {
   Map<String, Integer> map = new HashMap<String, Integer>();
   jp.nextToken();
   String nextFieldName = jp.getCurrentName();
   while (!nextFieldName.equals(ROWS_FIELD_NAME)) {
     jp.nextToken();
     map.put(nextFieldName, Integer.valueOf(jp.getIntValue()));
     jp.nextToken();
     nextFieldName = jp.getCurrentName();
   }
   return map;
 }
 private void skipToField(JsonParser jp, String fieldName, ParseState state)
     throws JsonParseException, IOException {
   String lastFieldName = null;
   while (jp.getCurrentToken() != null) {
     switch (jp.getCurrentToken()) {
       case FIELD_NAME:
         lastFieldName = jp.getCurrentName();
         jp.nextToken();
         break;
       case START_OBJECT:
         if (!state.inRow) {
           state.inRow = true;
           jp.nextToken();
         } else {
           if (isInField(fieldName, lastFieldName)) {
             return;
           } else {
             jp.skipChildren();
           }
         }
         break;
       default:
         if (isInField(fieldName, lastFieldName)) {
           jp.nextToken();
           return;
         }
         jp.nextToken();
         break;
     }
   }
 }
  @Override
  public EnumMap<?, ?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    // Ok: must point to START_OBJECT
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
      return _deserializeFromEmpty(jp, ctxt);
    }
    EnumMap result = constructMap();
    final JsonDeserializer<Object> valueDes = _valueDeserializer;
    final TypeDeserializer typeDeser = _valueTypeDeserializer;

    while ((jp.nextToken()) == JsonToken.FIELD_NAME) {
      String keyName = jp.getCurrentName(); // just for error message
      // but we need to let key deserializer handle it separately, nonetheless
      Enum<?> key = (Enum<?>) _keyDeserializer.deserializeKey(keyName, ctxt);
      if (key == null) {
        if (!ctxt.isEnabled(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL)) {
          throw ctxt.weirdStringException(
              keyName,
              _enumClass,
              "value not one of declared Enum instance names for " + _mapType.getKeyType());
        }
        /* 24-Mar-2012, tatu: Null won't work as a key anyway, so let's
         *  just skip the entry then. But we must skip the value as well, if so.
         */
        jp.nextToken();
        jp.skipChildren();
        continue;
      }
      // And then the value...
      JsonToken t = jp.nextToken();
      /* note: MUST check for nulls separately: deserializers will
       * not handle them (and maybe fail or return bogus data)
       */
      Object value;

      try {
        if (t == JsonToken.VALUE_NULL) {
          value = valueDes.getNullValue(ctxt);
        } else if (typeDeser == null) {
          value = valueDes.deserialize(jp, ctxt);
        } else {
          value = valueDes.deserializeWithType(jp, ctxt, typeDeser);
        }
      } catch (Exception e) {
        wrapAndThrow(e, result, keyName);
        return null;
      }
      result.put(key, value);
    }
    return result;
  }