public static byte [ ] toBytes ( Object value ) { try { return mapper . writeValueAsBytes ( value ) ; } catch ( Exception e ) { System . out . println ( e . getMessage ( ) ) ; throw new IllegalArgumentException ( String . format ( "Could not transform to bytes: %s" , e . getMessage ( ) ) ) ; } }
Convert an Object to an array of bytes .