A typical way to send binary to json is with base64 encoding. Java provides various methods for encoding Base64 and decoding a byte []. One of them is DatatypeConverter.
Very simple
byte[] originalBytes = new byte[] { 1, 2, 3, 4, 5}; String base64Encoded = DatatypeConverter.printBase64Binary(originalBytes); byte[] base64Decoded = DatatypeConverter.parseBase64Binary(base64Encoded);
Rohit source share