public static byte [ ] serialize ( Object instance ) throws JsonGenerationException , JsonMappingException , IOException { ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; mapper . writeValue ( out , instance ) ; return out . toByteArray ( ) ; }
Serialize the Object to JSON String .