title: java and json jackson property - different types at run-time
body: <p>I am calling an external web-service to get an object as json. This object has a property "value" which is sometimes a String and sometimes an array of Strings. </p>
  
  <pre><code>public class MyClass {
  
      // ... other variables
  
      private String value;
  
      public String getValue() {
          return value;
      }
  
      @JsonProperty("value")
      public void setValue(String value) {
          this.value = value;
      }
  }
  </code></pre>
  
  <p>Currently, I get an error <code>org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.lang.String out of START_ARRAY token</code> complaining about this field. I was wondering if some one could give me a hint on what is the correct way of defining <code>value</code> in my class.</p>
  
  <p>This is a part of a sample json that I have to deal with:</p>
  
  <pre><code>    {
        "id": 12016907001,
        "type": "Create",
        "value": "normal",
        "field_name": "priority"
      },
      {
        "id": 12016907011,
        "type": "Create",
        "value": [
          "sample",
          "another"
        ],
        "field_name": "tags"
      }
  </code></pre>
  
  <p>Thanks.</p>
  
  <p><strong>-- EDIT</strong></p>
  
  <p>I changed the type of the value to Object and it solved my problem. However, I am still wondering if there is a better way to handle this case.</p>