Enum SimpleJsonPrimitiveConverter
- All Implemented Interfaces:
IJsonPrimitiveConverter, Serializable, Comparable<SimpleJsonPrimitiveConverter>
public enum SimpleJsonPrimitiveConverter
extends Enum<SimpleJsonPrimitiveConverter>
implements IJsonPrimitiveConverter
A default
IJsonPrimitiveConverter that converts between JSON primitives and strings. It recognizes only the
primitive types defined by the JSON spec (null, boolean, number, boolean), represented by the usual Java classes
(Boolean, Number, String.
null, the empty string, as well as case-insensitive matches for "n", "f", "\0", "0", "false", "off" are converted to false. All other strings are converted to true.
Numbers are converted to their Base-10 representation. Floating point numbers are stringified as integers, when possible (i.e. 3.0 becomes "3").
- Since:
- 8.2.0
-
Enum Constant Summary
Enum Constants -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondeserializePrimitive(SerializedPrimitive primitive) Deserializes a primitive from a string, as serialized byIJsonPrimitiveConverter.serializePrimitive(Object).serializePrimitive(Object primitive) Serializes a primitive to a string.static SimpleJsonPrimitiveConverterReturns the enum constant of this type with the specified name.static SimpleJsonPrimitiveConverter[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
INSTANCE
The singleton instance of this converter.
-
-
Field Details
-
TYPE_BOOLEAN
-
TYPE_DOUBLE
-
TYPE_LONG
-
TYPE_NULL
-
TYPE_STRING
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
deserializePrimitive
Description copied from interface:IJsonPrimitiveConverterDeserializes a primitive from a string, as serialized byIJsonPrimitiveConverter.serializePrimitive(Object).- Specified by:
deserializePrimitivein interfaceIJsonPrimitiveConverter- Parameters:
primitive- The primitive to deserialize.- Returns:
- The deserialized primitive.
-
serializePrimitive
Description copied from interface:IJsonPrimitiveConverterSerializes a primitive to a string.- Specified by:
serializePrimitivein interfaceIJsonPrimitiveConverter- Parameters:
primitive- The primitive to serialize.- Returns:
- The serialized primitive.
-