title: Jackson databind enum case insensitive
body: <p>How can I deserialize  JSON string that contains enum values that are case insensitive? (using Jackson Databind)</p>
  
  <p>The JSON string:</p>
  
  <pre><code>[{"url": "foo", "type": "json"}]
  </code></pre>
  
  <p>and my Java POJO:</p>
  
  <pre><code>public static class Endpoint {
  
      public enum DataType {
          JSON, HTML
      }
  
      public String url;
      public DataType type;
  
      public Endpoint() {
  
      }
  
  }
  </code></pre>
  
  <p>in this case,deserializing the JSON with <code>"type":"json"</code> would fail where as <code>"type":"JSON"</code> would work.
  But I want <code>"json"</code> to work as well for naming convention reasons.</p>
  
  <p>Serializing the POJO also results in upper case <code>"type":"JSON"</code></p>
  
  <p>I thought of using <code>@JsonCreator</code> and @JsonGetter:</p>
  
  <pre><code>    @JsonCreator
      private Endpoint(@JsonProperty("name") String url, @JsonProperty("type") String type) {
          this.url = url;
          this.type = DataType.valueOf(type.toUpperCase());
      }
  
      //....
      @JsonGetter
      private String getType() {
          return type.name().toLowerCase();
      }
  </code></pre>
  
  <p>And it worked. But I was wondering whether there's a better solutuon because this looks like a hack to me. </p>
  
  <p>I can also write a custom deserializer but I got many different POJOs that use enums and it would be hard to maintain.</p>
  
  <p>Can anyone suggest a better way to serialize and deserialize enums with proper naming convention?</p>
  
  <p><strong>I don't want my enums in java to be lowercase!</strong></p>
  
  <p>Here is some test code that I used:</p>
  
  <pre><code>    String data = "[{\"url\":\"foo\", \"type\":\"json\"}]";
      Endpoint[] arr = new ObjectMapper().readValue(data, Endpoint[].class);
          System.out.println("POJO[]-&gt;" + Arrays.toString(arr));
          System.out.println("JSON -&gt;" + new ObjectMapper().writeValueAsString(arr));
  </code></pre>