public HostAndPort deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException
{
JsonToken t = jp.getCurrentToken();
if (t == JsonToken.START_OBJECT) { // old style
JsonNode root = jp.readValueAsTree();
String host = root.path("hostText").asText();
JsonNode n = root.get("port");
if (n == null) {
return HostAndPort.fromString(host);
}
return HostAndPort.fromParts(host, n.asInt());
}
if (t == JsonToken.VALUE_STRING) {
return HostAndPort.fromString(jp.getText().trim());
}
// could also support arrays?