title: JsonParseException: Unexpected character ('i' (code 105)): was expecting double-quote
body: <p>I am trying to integrate Spring Cloud streams and publishing a custom Java Object across services with RabbitMQ as broker. The object I am publishing looks like:</p>
  
  <pre><code>public class AppMessageEnvelope implements Serializable {
    ...
    private Object messageBody;
    private Date sentAt = new Date();
    ...
  
    // setters and getters
  }
  </code></pre>
  
  <p>This is just a wrapper object and the original object is put in <code>messageBody</code>. The object I am putting in <code>messageBody</code> looks like:</p>
  
  <pre><code>public class Job {
      ...
      private String message;
      private Map&lt;MyEnum, String&gt; myMap;
      ...
  }
  </code></pre>
  
  <p>Note that both <code>AppMessageEnvelope</code> and <code>Job</code> are in a different <strong>model</strong> project which is imported as a Maven dependency in the publisher and subscriber Spring Boot projects, so models are exactly the same.</p>
  
  <p>In producer, I publish the object as:</p>
  
  <pre><code>@EnableBinding(Source.class)
  public class JobDistributor {
  
      private final Source jobQueue;
  
      @Autowired
      public JobDistributor(Source jobQueue) {
          this.jobQueue = jobQueue;
      }
  
      public AppMessageEnvelope publishJob(AppMessageEnvelope message) {
          LOG.info("Sending message: {}.", message);
          jobQueue.output().send(MessageBuilder.withPayload(message).build());
          return message;
      }
  }
  </code></pre>
  
  <p>In consumer, I get the message as:</p>
  
  <pre><code>@Component
  @EnableBinding(Sink.class)
  public class JobConsumer {
  
      private final JobManager jobManager;
      private final ObjectMapper objectMapper;
  
      @Autowired
      public JobConsumer(
              JobManager jobManager, ObjectMapper objectMapper) {
          this.jobManager = jobManager;
          this.objectMapper = objectMapper;
      }
  
      @StreamListener(target = Sink.INPUT)
      public void processData(AppMessageEnvelope messageEnvelope) {
          LOG.info("Envelope received: {}.", messageEnvelope);
  
          try {
              TypeReference&lt;Job&gt; mapType = new TypeReference&lt;Job&gt;() {};
              Job job = objectMapper.readValue(messageEnvelope.getMessageBody().toString(), mapType);
              jobManager.processRequest(job);
          } catch (Exception ex) {
              LOG.error("Couldn't convert to correct object for processing: {}.", ex);
          }
      }
  }
  </code></pre>
  
  <p>I try to use <code>TypeReference</code> to convert the internal object into a correct object but I get an error as:</p>
  
  <pre><code>JobConsumer - Couldn't convert to correct object for processing: {}.
      com.fasterxml.jackson.core.JsonParseException: Unexpected character ('i' (code 105)): was expecting double-quote to start field name
      at [Source: (StringReader); line: 1, column: 3]
  </code></pre>
  
  <p>Before the message is converted, I log it:</p>
  
  <pre><code>JobConsumer - Envelope received: AppMessageEnvelope{..., messageBody={id=5bf3a7302dbe9c7cf9927c60, jobId=8c0bfcb0b21248e694b5cd52337a1f9e, submittedAt=2018-11-20T06:18:24+0000, lastUpdatedOn=null, message=null, ..., fileContentMap={FILE_BYTES=JVBERi0xLjUKJb/3ov}}, sentAt=Tue Nov 20 11:48:24 IST 2018}
  </code></pre>
  
  <p>I tried configuring <code>ObjectMapper</code> as:</p>
  
  <pre><code>@Autowired
  private ObjectMapper objectMapper() {
      JsonFactory factory = new JsonFactory();
      factory.enable(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES);
      return new ObjectMapper(factory);
  }
  </code></pre>
  
  <p>I tried enabling unquoting fields with this too:</p>
  
  <pre><code>objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
  </code></pre>
  
  <p>I tried solutions provided by <a href="https://www.mkyong.com/java/jackson-was-expecting-double-quote-to-start-field-name/" rel="nofollow noreferrer">this blog</a> and some similar SO problem but nothing solved. What am I missing?</p>