static Endpoint parseEndpoint(JsonParser parser) throws IOException {
    if (!parser.isExpectedStartObjectToken()) {
      throw new IllegalArgumentException("Not a valid JSON object, start token: " +
        parser.currentToken());
    }

    String serviceName = null, ipv4 = null, ipv6 = null;
    int port = 0;

    while (parser.nextToken() != JsonToken.END_OBJECT) {
      JsonToken value = parser.nextValue();
      if (value == JsonToken.VALUE_NULL) {
        continue;
      }

      switch (parser.currentName()) {
        case "serviceName":
          serviceName = parser.getText();
          break;
        case "ipv4":
          ipv4 = parser.getText();
          break;
        case "ipv6":
          ipv6 = parser.getText();
          break;
        case "port":
          port = parser.getIntValue();
          break;
        default:
          // Skip
      }
    }

    if (serviceName == null && ipv4 == null && ipv6 == null && port == 0) return null;
    return Endpoint.newBuilder()
      .serviceName(serviceName)
      .ip(ipv4)
      .ip(ipv6)
      .port(port)
      .build();
  }
JSON serialization utilities and parsing code.
zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/internal/JsonSerializers.java