NoneableDouble

@JsonQualifier()
public @interface NoneableDouble

Marks a Double field as carrying Alpha Vantage's numeric-or-"None" convention, routing its deserialization through NoneableDoubleAdapter instead of Moshi's default Double handling.

Several Alpha Vantage endpoints report a numeric field that hasn't been computed yet — for example a company overview's price-to-earnings ratio before the company has reported earnings — as the literal JSON string "None", rather than omitting the key or sending JSON null. Moshi cannot coerce that string into a Double on its own, so a field holding such a value fails to parse unless something intercepts it; a plain Optional<Double> field wouldn't help either, since the problem is the incoming string, not the field's nullability. Annotating the field with this qualifier instead redirects its deserialization to NoneableDoubleAdapter, which distinguishes Alpha Vantage's explicit "None" placeholder from an ordinary numeric value by producing null for the former.

This annotation carries no data of its own; it is a Moshi JsonQualifier used purely to select the adapter.

Author

Sylvester Sefa-Yeboah

Since

1.7.0

Functions

Link copied to clipboard
public abstract Class<? extends Annotation> annotationType()
Link copied to clipboard
public abstract boolean equals(Object p)
Link copied to clipboard
public abstract int hashCode()
Link copied to clipboard
public abstract String toString()