class NpmFieldDeserializer {

  public Object deserialize(final String fieldName,
                            final Object defaultValue,
                            final JsonParser parser,
                            final DeserializationContext context,
                            final JsonGenerator generator) throws IOException
  {
    generator.writeFieldName(fieldName);

    Object value;

    try {
      value = deserializeValue(defaultValue);
    }
    catch (RuntimeException e) {
      // handle the most likely exception from deserializing and throw as a normal deserializer would
      if (e.getCause() instanceof IOException) {
        throw (IOException) e.getCause();
      }

      throw e;
    }

    if (nonNull(value) || parser.currentTokenId() == ID_NULL) {
      generator.writeObject(value);
    }

    return value;
  }

}