Code example for JsonReader

Methods: nextNullpeek

0
  public static final TypeAdapterFactory URI_FACTORY = newFactory(URI.class, URI);
 
  public static final TypeAdapter<InetAddress> INET_ADDRESS = new TypeAdapter<InetAddress>() {
    @Override 
    public InetAddress read(JsonReader in) throws IOException { 
      if (in.peek() == JsonToken.NULL) { 
        in.nextNull(); 
        return null; 
      } 
      // regrettably, this should have included both the host name and the host address 
      return InetAddress.getByName(in.nextString()); 
    } 
    @Override 
    public void write(JsonWriter out, InetAddress value) throws IOException { 
      out.value(value == null ? null : value.getHostAddress()); 
    } 
  }; 
 
  public static final TypeAdapterFactory INET_ADDRESS_FACTORY =
    newTypeHierarchyFactory(InetAddress.class, INET_ADDRESS);
Experience pair programming with AI  Get Codota for Java