title: JSON parse error: Cannot deserialize instance of `byte[]` out of START_OBJECT token
body: <p>How to send a base64 image in postman json format. I was added image file in postman- body form data and it's encode details in json format but i got a bad request only in my attempts. [JSON parse error: Cannot deserialize instance of <code>byte[]</code> out of START_OBJECT token]. found that there is no error in source but the actual issue in json format in postman. SOURCE: <a href="https://github.com/arun0009/ocr-tess4j-rest" rel="nofollow noreferrer">https://github.com/arun0009/ocr-tess4j-rest</a></p>
  
  <p>I applied a stack overflow solution but it's repeating the same error. I was adding <code>[]</code>, <code>{}</code> in my json formats from stack overflow suggestion types.</p>
  
  <p>CLASS:</p>
  
  <pre><code>public class Image  {
      private String id;
      private String userId;
      private byte[] image;
      private String extension;
      private String text;  }
  </code></pre>
  
  <p>CONTROLLER :</p>
  
  <pre><code>@RequestMapping(value = "ocr/v1/upload", method= RequestMethod.POST,consumes= MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
  public Status doOcr(@RequestBody Image image) throws Exception {
  try {      ByteArrayInputStream bis = new ByteArrayInputStream(Base64.decodeBase64(image.getImage()));
              Tesseract tesseract = new Tesseract(); // JNA Interface Mapping
              String imageText = tesseract.doOCR(ImageIO.read(bis));
              image.setText(imageText);
              repository.save(image);
              LOGGER.debug("OCR Result = " + imageText);
       } catch (Exception e) {
     LOGGER.error("TessearctException while converting/uploading image: ", e);
              throw new TesseractException();     }
  </code></pre>
  
  <p>TEST CASE:</p>
  
  <pre><code>@Test
      public void testDoOcr() throws IOException {
          Map&lt;String, String&gt; headers = new HashMap&lt;String, String&gt;();
          headers.put("Accept", MediaType.APPLICATION_JSON_VALUE);
          headers.put("Content-Type", MediaType.APPLICATION_JSON_VALUE);
          Image image = new Image();
  InputStream inputStream=lassLoader.getSystemResourceAsStream("eurotext.png");
          image.setUserId("arun0009");
          image.setExtension(".png");
         image.setImage(Base64.encodeBase64(IOUtils.toByteArray(inputStream)));
  String response=given().contentType("application/json").headers(headers) .body(image).when().post("http://localhost:8080/ocr/v1/upload").then()
  .statusCode(200).extract().response().body().asString();        System.out.println(response);  }
  </code></pre>
  
  <p>JSON:</p>
  
  <pre><code>    { "image": {  
                 "userId": "arun0009", 
                  "extension": ".png",    
                  "text": "iVBORw0KGgoA"  
     }
  </code></pre>
  
  <p><strong>JSON parse error:</strong> </p>
  
  <blockquote>
    <p>Cannot deserialize instance of <code>byte[]</code> out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of <code>byte[]</code> out of START_OBJECT token\n at [Source: (PushbackInputStream);</p>
  </blockquote>