
com.smartystreets.api.SmartySerializer Maven / Gradle / Ivy
package com.smartystreets.api;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.*;
public class SmartySerializer implements Serializer {
public SmartySerializer() {}
public byte[] serialize(Object obj) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
return mapper.writeValueAsBytes(obj);
}
public T deserialize(byte[] payload, Class type) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return mapper.readValue(payload, type);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy