title: Deserialize java enum from JSON
body: <p>We use Jackson 1.9.1 to serialize and deserialize JSON request response strings to/from Java objects. Primitive Java types, collection types, and custom objects are (de)serialized without issues. However, I have a problem trying to deserialize JSON string into java enum.
  JSON string is serialized like so:</p>
  
  <pre><code>"wt":{"wt":100.5,"unit":{"LBS":3}}
  </code></pre>
  
  <p>Java type for wt is like so:</p>
  
  <pre><code>public class Weight {
  
      protected double weight;
      protected Unit unit;
  }
  </code></pre>
  
  <p>I referred to <a href="https://stackoverflow.com/questions/9300191/how-to-annotate-enum-fields-for-deserialization-using-jackson-json">this</a>, <a href="https://stackoverflow.com/questions/12468764/jackson-enum-serializing-and-deserializer">this</a>, and <a href="https://stackoverflow.com/questions/12692081/deserialize-json-to-java-enum">this</a> on SO and came up with enum for weight units like so:</p>
  
  <pre><code>public enum Unit {
  
      KG("kg"),
      GM("gm"),
      LBS("lbs"),
      OZ("oz");
  
      private String value;  
      private WeightMeasurementUnit(String value) { this.value = value; }
  
      @JsonValue
      public String getValue() { return this.value; }
  
      @JsonCreator
      public static Unit create(String val) {
          Unit[] units = Unit.values();
          for (Unit unit : units) {
              if (unit.getValue().equals(val)) {
                  return unit;
              }
          }
          return LBS;
      }
  }
  </code></pre>
  
  <p>The problem is, when ever I try to deserialize above mentioned JSON I get this error saying: "Unrecognized field "LBS" (Class a.b.c.d.Weight), not marked as ignorable" Exception stacktrace is like so:</p>
  
  <pre><code>Caused by: org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "LBS" (Class a.b.c.d.Weight), not marked as ignorable
   at [Source: java.io.ByteArrayInputStream@20172017; line: 1, column: 464] (through reference chain: a.b.c.d.MyRequest["blah"]-&gt;a.b.c.d.AnotherType["wt"]-&gt;a.b.c.d.Weight["LBS"])
      at org.codehaus.jackson.map.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:53)
      at org.codehaus.jackson.map.deser.StdDeserializationContext.unknownFieldException(StdDeserializationContext.java:267)
      at org.codehaus.jackson.map.deser.std.StdDeserializer.reportUnknownProperty(StdDeserializer.java:673)
      at org.codehaus.jackson.map.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:659)
      at org.codehaus.jackson.map.deser.BeanDeserializer.handleUnknownProperty(BeanDeserializer.java:1365)
  </code></pre>
  
  <p>...</p>
  
  <p>My questions are:
  Is the serialized JSON string for enum seem correct ?
  What else should I include (or annotate) for the enum to be properly deserialized ?</p>