title: Deserializing byte array from json string
body: <p>I have Dto with field of byte array and json string, serialized with JSON.stringify and service, that should parse this string.</p>
  
  <pre><code>@Data
  @NoArgsConstructor
  @AllArgsConstructor
  public class CompanyDto {
  
      private UUID id;
      private String name;
      private boolean isVerified;
      private String description;
      private byte[] fileData;
      private UUID accountId;
  }
  </code></pre>
  
  <pre><code>    @Override
      public CompanyDto parseCompanyDto(String s) {
          ObjectMapper objectMapper = new ObjectMapper();
          objectMapper.registerModule(new Hibernate5Module());
          try {
              return objectMapper.readValue(s, CompanyDto.class);
          } catch (JsonProcessingException e) {
              e.printStackTrace();
              return null;
          }
      }
  </code></pre>
  
  <p>If fileData in input string is null, this service works well, but it can't deserialize byte array from string, serialized on frontend. It fails with exeption: </p>
  
  <pre><code>com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `[B` out of START_OBJECT token
   at [Source: (String)"{"name":"testCompany","description":"test test test","fileData":{"0":255,"1":216,"2":255,"3":224,"4":0,"5":16,"6":74,"7":70,"8":73,"9":70,"10":0,"11":1,"12":1,"13":2,"14":0,"15":56,"16":0,"17":56,"18":0,"19":0,"20":255,"21":219,"22":0,"23":67,"24":0,"25":2,"26":2,"27":2,"28":2,"29":2,"30":1,"31":2,"32":2,"33":2,"34":2,"35":3,"36":2,"37":2,"38":3,"39":3,"40":6,"41":4,"42":3,"43":3,"44":3,"45":3,"46":7,"47":5,"48":5,"49":4,"50":6,"51":8,"52":7,"53":9,"54":8,"55":8,"56":7,"57":8,"58":8,"59":9,"60":"[truncated 25008 chars]; line: 1, column: 65] (through reference chain: edu.netcracker.jobdealer.dto.CompanyDto["fileData"])
      at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
      at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1442)
      at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1216)
      at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1126)
      at com.fasterxml.jackson.databind.deser.std.PrimitiveArrayDeserializers.handleNonArray(PrimitiveArrayDeserializers.java:240)
      at com.fasterxml.jackson.databind.deser.std.PrimitiveArrayDeserializers$ByteDeser.deserialize(PrimitiveArrayDeserializers.java:498)
      at com.fasterxml.jackson.databind.deser.std.PrimitiveArrayDeserializers$ByteDeser.deserialize(PrimitiveArrayDeserializers.java:446)
      at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
      at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
      at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
      at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4202)
      at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3205)
      at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3173)
      at service.impl.JsonServiceImpl.parseCompanyDto(JsonServiceImpl.java:51)
  </code></pre>
  
  <p>I tried to send fileData separately using URlSearchParams.append and it worked well, but it sounds like a dirty hack.</p>
  
  <p>Can you say, what <em>instance of <code>[B</code></em> means and how to parse it correctly?</p>