title: Parsing JSON to POJO with LocalDateTime using Jackson "Unexpected token (START_OBJECT), expected VALUE_STRING: Expected array or string."
body: <p>I have read many postings on here on JSON parsing to Java objects and have had my parsing working just fine until I introduced LocalDateTime.  I have tried to using the Java 8 parser, the JSR310 module and to build a customization - below describing the roadblocks on each.  Any help would be appreciated!</p>
  
  <p>This is my JSON string, creating by Jackson from another POJO:</p>
  
  <pre><code>{"validEscortsWTheirSpecReqs":"MAYBE",
   "modifiedDateTimeNeedToBeThere":     
      {"dayOfMonth":6,"dayOfWeek":"MONDAY","month":"FEBRUARY","year":2017,
       "hour":10,"minute":1,"second":24,"nano":0,"dayOfYear":37,"monthValue":2,
       "chronology":{"id":"ISO","calendarType":"iso8601"}
      }
  }
  </code></pre>
  
  <p>which generates </p>
  
  <pre><code>com.fasterxml.jackson.databind.JsonMappingException: Unexpected token (START_OBJECT), expected VALUE_STRING: Expected array or string. at 
  ...
      at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:270)
      at com.fasterxml.jackson.databind.DeserializationContext.wrongTokenException(DeserializationContext.java:1376)
      at com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer.deserialize(LocalDateTimeDeserializer.java:118)
      at com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer.deserialize(LocalDateTimeDeserializer.java:39)
  ...
  </code></pre>
  
  <p>called from:</p>
  
  <p>ComputeArrive response = mapper.readValue(responseString, ComputeArrive.class);</p>
  
  <p>Response has the following fields:</p>
  
  <p>Logger logger // should not be mapped by JSON, no getters/setters
  static final long serialVersionUID = 1L;   // "
  String validEscortsWTheirSpecReqs = "YES"  // want mapped
  LocalDateTime modifiedDateTimeNeedToBeThere // want mapped</p>
  
  <p>I have probably registered too many modules by now, adding them in to try to get it to parse:</p>
  
  <pre><code>    mapper.findAndRegisterModules();
      //mapper           .registerModule(new ParameterNamesModule());
      mapper.registerModule(new Jdk8Module());
      mapper.registerModule(new JavaTimeModule());
      mapper.registerModule(new JSR310Module());
  </code></pre>
  
  <p>So I have tried to add Spring Boot dependencies to my project and write a customizer for JSR310 (which seems unecessary given the modules above):</p>
  
  <pre><code>@Configuration
  public class JacksonConfig {
  
      @Bean
      @Primary
      public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
          ObjectMapper objectMapper = builder.createXmlMapper(false).build();
          objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
          objectMapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false);
          return objectMapper;
      }
  }
  </code></pre>
  
  <p>My application has numerous dependencies so I did not want to make anything a "parent" of it and added the following dependencies.  However, the class "Jackson2ObjectMapperBuilder" is not being found so the above does not compiles with these dependencies:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.springframework&lt;/groupId&gt;
      &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
      &lt;version&gt;4.3.5.RELEASE&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.springframework&lt;/groupId&gt;
      &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
      &lt;version&gt;4.3.5.RELEASE&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.springframework&lt;/groupId&gt;
      &lt;artifactId&gt;spring-beans&lt;/artifactId&gt;
      &lt;version&gt;4.3.5.RELEASE&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.springframework&lt;/groupId&gt;
      &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
      &lt;version&gt;4.3.5.RELEASE&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.springframework&lt;/groupId&gt;
      &lt;artifactId&gt;spring-expression&lt;/artifactId&gt;
      &lt;version&gt;4.3.5.RELEASE&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.springframework&lt;/groupId&gt;
      &lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
      &lt;version&gt;4.3.5.RELEASE&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;aopalliance&lt;/groupId&gt;
      &lt;artifactId&gt;aopalliance&lt;/artifactId&gt;
      &lt;version&gt;1.0&lt;/version&gt;
  &lt;/dependency&gt;   
  </code></pre>
  
  <p>I am not finding a lot of documentation for "Jackson2ObjectMapperBuilderCustomizer" which may be a replacement for "Jackson2ObjectMapperBuilder" - which could be the issue. Please note that the class above is not instantiated by me because I assume Spring instantiates it.</p>
  
  <p>Any thoughts on how to parse my response would be most appreciated!</p>