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