title: how to get property or field name in a custom json serializer
body: <p>I have a <a href="https://fasterxml.github.io/jackson-databind/javadoc/2.6/com/fasterxml/jackson/databind/JsonSerializer.html" rel="nofollow noreferrer">custom JsonSerializer</a> for a field (simplified code):</p>
  
  <pre class="lang-java prettyprint-override"><code>@JsonSerialize(using=Text1Serializer.class)
  @JsonProperty("text1") // I need this inside the custom serializer
  @Override
  public String getTextOne() {
      return "foo";
  }
  
  // ...
  
  public static class Text1Serializerextends JsonSerializer&lt;String&gt; {
  
      @Override
      public void serialize(String value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
          // how to get "text1" here?
          provider.defaultSerializeValue(value, jgen);
      }
  
  }
  </code></pre>
  
  <p>Since I need to serialize about ten other fields with a similar logic, that just depends on the field <em>name</em>, it would help me very much if I could get the property name inside the custom serializer - instead of writing ten identical serializers.</p>
  
  <p>I've seen that inside the <code>serialize()</code> method I can get the whole object with <code>JsonGenerator.getCurrentValue()</code> (see <a href="https://stackoverflow.com/a/33414406/3127111">this answer</a>), but I didnt' find a way to get the field name.</p>
  
  <p>I'm using Jackson 2.6</p>