com.maxmind.geoip2.model.AbstractResponse Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of geoip2 Show documentation
Show all versions of geoip2 Show documentation
GeoIP2 webservice client and database reader
package com.maxmind.geoip2.model;
import java.io.IOException;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.ObjectMapper;
public abstract class AbstractResponse {
/**
* @return JSON representation of this object. The structure is the same as
* the JSON provided by the GeoIP2 web service.
* @throws IOException if there is an error serializing the object to JSON.
*/
public String toJson() throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(Include.NON_NULL);
mapper.setSerializationInclusion(Include.NON_EMPTY);
return mapper.writeValueAsString(this);
}
}