looks like you may be able to re-used methods from org.springframework.util.SerializationUtils for this