Enum Class JSONOptions.ConversionMode

java.lang.Object
java.lang.Enum<JSONOptions.ConversionMode>
com.upokecenter.cbor.JSONOptions.ConversionMode
All Implemented Interfaces:
Serializable, Comparable<JSONOptions.ConversionMode>, Constable
Enclosing class:
JSONOptions

public static enum JSONOptions.ConversionMode extends 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

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    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 the CBORObject.FromObject(EDecimal) method.
    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).
    JSON numbers are decoded to CBOR using the full precision given in the JSON text.
    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.
    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.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the enum constant of this class with the specified name.
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • Full

      public static final JSONOptions.ConversionMode 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 the CBORObject.FromObject(EInteger) method; otherwise, use the rules given in the CBORObject.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

      public static final JSONOptions.ConversionMode 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 how EncodeToBytes and other methods encode CBOR objects. Notably, by default, EncodeToBytes encodes 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

      public static final JSONOptions.ConversionMode 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 how EncodeToBytes and other methods encode CBOR objects. Notably, by default, EncodeToBytes encodes 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

      public static final JSONOptions.ConversionMode 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 how EncodeToBytes and other methods encode CBOR objects. Notably, by default, EncodeToBytes encodes 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

      public static final JSONOptions.ConversionMode 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 the CBORObject.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

      public static JSONOptions.ConversionMode[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static JSONOptions.ConversionMode valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified name
      NullPointerException - if the argument is null