Top Description Fields Constructors Methods
com.google.gson

public sealed Enum ToNumberPolicy

extends Enum<ToNumberPolicy>
implements ToNumberStrategy
Class Inheritance
All Implemented Interfaces
com.google.gson.ToNumberStrategy
Imports
com.google.gson.internal.LazilyParsedNumber, .NumberLimits, com.google.gson.stream.JsonReader, .MalformedJsonException, java.io.IOException, java.math.BigDecimal

An enumeration that defines two standard number reading strategies and a couple of strategies to overcome some historical Gson limitations while deserializing numbers as Object and Number.
Since
2.8.9
See Also
ToNumberStrategy

Field Summary

Modifier and TypeField and Description
public static final ToNumberPolicy
BIG_DECIMAL

Using this policy will ensure that numbers will be read as numbers of arbitrary length using BigDecimal.

public static final ToNumberPolicy
DOUBLE

Using this policy will ensure that numbers will be read as Double values.

public static final ToNumberPolicy
LAZILY_PARSED_NUMBER

Using this policy will ensure that numbers will be read as a lazily parsed number backed by a string.

public static final ToNumberPolicy
LONG_OR_DOUBLE

Using this policy will ensure that numbers will be read as Long or Double values depending on how JSON numbers are represented: Long if the JSON number can be parsed as a Long value, or otherwise Double if it can be parsed as a Double value.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ToNumberPolicy
public static ToNumberPolicy[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

BIG_DECIMALback to summary
public static final ToNumberPolicy BIG_DECIMAL

Using this policy will ensure that numbers will be read as numbers of arbitrary length using BigDecimal.

DOUBLEback to summary
public static final ToNumberPolicy DOUBLE

Using this policy will ensure that numbers will be read as Double values. This is the default strategy used during deserialization of numbers as Object.

LAZILY_PARSED_NUMBERback to summary
public static final ToNumberPolicy LAZILY_PARSED_NUMBER

Using this policy will ensure that numbers will be read as a lazily parsed number backed by a string. This is the default strategy used during deserialization of numbers as Number.

LONG_OR_DOUBLEback to summary
public static final ToNumberPolicy LONG_OR_DOUBLE

Using this policy will ensure that numbers will be read as Long or Double values depending on how JSON numbers are represented: Long if the JSON number can be parsed as a Long value, or otherwise Double if it can be parsed as a Double value. If the parsed double-precision number results in a positive or negative infinity (Double#isInfinite()) or a NaN (Double#isNaN()) value and the JsonReader is not lenient, a MalformedJsonException is thrown.

Constructor Detail

ToNumberPolicyback to summary
private ToNumberPolicy()

Method Detail

valueOfback to summary
public static ToNumberPolicy valueOf(String name)
valuesback to summary
public static ToNumberPolicy[] values()