name.valery1707.smsc.JsonMapperJackson Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of smsc-json-jackson Show documentation
Show all versions of smsc-json-jackson Show documentation
JSON mapper layer implementation: Jackson
The newest version!
package name.valery1707.smsc;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.type.CollectionType;
import java.io.IOException;
import java.util.List;
public class JsonMapperJackson implements JsonMapper {
private final ObjectMapper mapper;
public JsonMapperJackson() {
mapper = new ObjectMapper()
.findAndRegisterModules()
.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
}
@Override
public T single(String json, Class clazz) throws IOException {
return mapper.readValue(json, clazz);
}
@Override
public List multi(String json, Class clazz) throws IOException {
CollectionType type = mapper.getTypeFactory().constructCollectionType(List.class, clazz);
return mapper.readValue(json, type);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy