Package com.upokecenter.cbor
Enum JSONOptions.ConversionMode
java.lang.Object
java.lang.Enum<JSONOptions.ConversionMode>
com.upokecenter.cbor.JSONOptions.ConversionMode
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<JSONOptions.ConversionMode>,java.lang.constant.Constable
- Enclosing class:
- JSONOptions
public static enum JSONOptions.ConversionMode extends java.lang.Enum<JSONOptions.ConversionMode>
Specifies how JSON numbers are converted to CBOR objects when decoding JSON
(such as via
FromJSONString or ReadJSON). None of
these conversion modes affects how CBOR objects are later encoded
(such as via EncodeToBytes).-
Nested Class Summary
-
Enum Constant Summary
Enum Constants Enum Constant Description Decimal128JSON numbers are decoded to CBOR as their closest-rounded approximation to an IEEE 854 decimal128 value, using the round-to-nearest/ties-to-even rounding mode and the rules for the EDecimal form of that approximation as given in theCBORObject.FromObject(EDecimal)method.DoubleJSON numbers are decoded to CBOR as their closest-rounded approximation as 64-bit binary floating-point numbers (using the round-to-nearest/ties-to-even rounding mode).FullJSON numbers are decoded to CBOR using the full precision given in the JSON text.IntOrFloatA JSON number is decoded to CBOR objects either as a CBOR integer (major type 0 or 1) if the JSON number represents an integer at least -(2^53)+1 and less than 2^53, or as their closest-rounded approximation as 64-bit binary floating-point numbers (using the round-to-nearest/ties-to-even rounding mode) otherwise.IntOrFloatFromDoubleA JSON number is decoded to CBOR objects either as a CBOR integer (major type 0 or 1) if the number's closest-rounded approximation as a 64-bit binary floating-point number (using the round-to-nearest/ties-to-even rounding mode) represents an integer at least -(2^53)+1 and less than 2^53, or as that approximation otherwise. -
Method Summary
Modifier and Type Method Description static JSONOptions.ConversionModevalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static JSONOptions.ConversionMode[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
Full
JSON numbers are decoded to CBOR using the full precision given in the JSON text. The number will be converted to a CBOR object as follows: If the number's exponent is 0 (after shifting the decimal point to the end of the number without changing its value), use the rules given in theCBORObject.FromObject(EInteger)method; otherwise, use the rules given in theCBORObject.FromObject(EDecimal)method. An exception in version 4.x involves negative zeros; if the negative zero's exponent is 0, it's written as a CBOR floating-point number; otherwise the negative zero is written as an EDecimal. -
Double
JSON numbers are decoded to CBOR as their closest-rounded approximation as 64-bit binary floating-point numbers (using the round-to-nearest/ties-to-even rounding mode). (In some cases, numbers extremely close to zero may underflow to positive or negative zero, and numbers of extremely large absolute value may overflow to infinity.). It's important to note that this mode affects only how JSON numbers are decoded to a CBOR object; it doesn't affect howEncodeToBytesand other methods encode CBOR objects. Notably, by default,EncodeToBytesencodes CBOR floating-point values to the CBOR format in their 16-bit ("half-float"), 32-bit ("single-precision"), or 64-bit ("double-precision") encoding form depending on the value. -
IntOrFloat
A JSON number is decoded to CBOR objects either as a CBOR integer (major type 0 or 1) if the JSON number represents an integer at least -(2^53)+1 and less than 2^53, or as their closest-rounded approximation as 64-bit binary floating-point numbers (using the round-to-nearest/ties-to-even rounding mode) otherwise. For example, the JSON number 0.99999999999999999999999999999999999 is not an integer, so it's converted to its closest 64-bit binary floating-point approximation, namely 1.0. (In some cases, numbers extremely close to zero may underflow to positive or negative zero, and numbers of extremely large absolute value may overflow to infinity.). It's important to note that this mode affects only how JSON numbers are decoded to a CBOR object; it doesn't affect howEncodeToBytesand other methods encode CBOR objects. Notably, by default,EncodeToBytesencodes CBOR floating-point values to the CBOR format in their 16-bit ("half-float"), 32-bit ("single-precision"), or 64-bit ("double-precision") encoding form depending on the value. -
IntOrFloatFromDouble
A JSON number is decoded to CBOR objects either as a CBOR integer (major type 0 or 1) if the number's closest-rounded approximation as a 64-bit binary floating-point number (using the round-to-nearest/ties-to-even rounding mode) represents an integer at least -(2^53)+1 and less than 2^53, or as that approximation otherwise. For example, the JSON number 0.99999999999999999999999999999999999 is the integer 1 when rounded to its closest 64-bit binary floating-point approximation (1.0), so it's converted to the CBOR integer 1 (major type 0). (In some cases, numbers extremely close to zero may underflow to zero, and numbers of extremely large absolute value may overflow to infinity.). It's important to note that this mode affects only how JSON numbers are decoded to a CBOR object; it doesn't affect howEncodeToBytesand other methods encode CBOR objects. Notably, by default,EncodeToBytesencodes CBOR floating-point values to the CBOR format in their 16-bit ("half-float"), 32-bit ("single-precision"), or 64-bit ("double-precision") encoding form depending on the value. -
Decimal128
JSON numbers are decoded to CBOR as their closest-rounded approximation to an IEEE 854 decimal128 value, using the round-to-nearest/ties-to-even rounding mode and the rules for the EDecimal form of that approximation as given in theCBORObject.FromObject(EDecimal)method. (In some cases, numbers extremely close to zero may underflow to zero, and numbers of extremely large absolute value may overflow to infinity.).
-
-
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:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
-