Consider the following class:
class MyObject {
@JsonProperty("name")
String name = "Hello world";
@JsonProperty("data")
byte[] data = new byte[] {10, 20, 30, 40};
}
In the main class I have:
class Main {
MyObject mo1 = new MyObject(), mo2 = new MyObject();
List<MyObject> myList = Arrays.asList(mo1, mo2);
byte[] serialize() {
return new ObjectMapper().writeValueAsBytes(myList);
}
void deserialize(byte[] in) {
myList = new ObjectMapper().readValue(in, List.class);
}
}
What happens is that the value of data is saved as base64 (and it's correct) but when deserializing, data is not being converted back to byte[], rather as _StringWithBase64_.getBytes().
Is there any solution without using custom deserializer, like configuring ObjectMapper to decode base64 when loading into byte[]?
>() { });`
– Andreas Sep 22 '18 at 05:36