hirezapi.json.deserializer.BooleanTextDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of HiRezApi-common Show documentation
Show all versions of HiRezApi-common Show documentation
Java-Based API Wrapper for Hi-Rez Studios games.
The newest version!
package hirezapi.json.deserializer;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import java.io.IOException;
public class BooleanTextDeserializer extends JsonDeserializer {
@Override
public Boolean deserialize(JsonParser p, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
try {
return p.getBooleanValue();
} catch (IOException ignore) {
String b = p.getText();
if (b.equalsIgnoreCase("y")) {
return true;
} else if (b.equalsIgnoreCase("n")) {
return false;
}
return false;
}
}
}