Package Torello.JSON

Class ReadBoxedJSON


  • public class ReadBoxedJSON
    extends java.lang.Object
    Builds on the J2EE Standard Release JSON Parsing Tools by providing additional help with converting JSON Data into Java Boxed-Primitive Types

    This class builds on the J2EE Standard 'Glass-Fish' JSON Processor


    There are several JSON Parsers available, and even more implementations for serializing and de-serializing data to/from JSON. The Glass Fish Tool is included in the J2EE, and is available on GitHub. That is the one used by the Java HTML JAR Library (See: javax.json.* )

    Primary Classes Used: JsonArray and JsonObject


    This comment-note is intentionally repeated, verbatim, at the top of all Json Reader Classes in this package.


    JSON to Java Binding:
    JSON-Binding is the art of converting data that has been stored, saved or transmitted using Java-Script Object Notation into a Java Primitive or Object-Type. JSON can arrive into Java-Program Memory from almost any source. If you are wondering why such a massive amount of "work" is necessary just to convert a Json Integer into Java Integer, the value added is the extraordinary amount of attention paid to user configuration, error checking, & exception messaging. Methods here don't require more than 1 or 2 lines of code, and guarantee that a thorough type checking is performed.

    Unlike Java-Types which are checked by the Java-Compiler each-and-every time a programmer compiles his project, any guarantee that JSON-Type Data is pristine, uncorrupted, and in any kind of pre-agreed format may or may not be assured. The methods here are able to handle changes that might be made to an API (possibly from great distances away, and without the Software-Manager's consent). If an error could occur, configuration flags can be used to determine default error-recovery behaviors. If an exception does throw, the exception messages printed will contain multiple lines of detailed information.

    • Utilizes the Java-Standard javax.json.* Package-Library, & its Glass-Fish Implementation
    • Handles the Transfer & Conversion of All Json-Type's into Java-Type's with just One Line of Code
    • Provides all manner of User-Configurable Exception-Handling & Error-Decision Management via Class JFlag
    • Provides a Fine-Grained Suite of Exception-Classes, all with Consistent & Meaningful Error-Messages. Json Files can occasionally grow extremely large, and error messaging details make debugging easier
    • Primary Helper-Classes for the (Experimental) Google-Chrome Browser Automation Package

    The goal of Torello.JSON is to provide small, static helper methods in the same spirit as java.util.Objects and java.util.Arrays: simple calls that keep JSON handling out of your application logic. Instead of repeating loops, type checks, null checks, and exception wiring at every call site, these methods centralize that work behind a consistent set of straight-forward “read value” operations.


    Reads a single Json value from a Json Array or Object and returns a boxed primitive

    For seven out of the eight Java Primitive Types, this class provides four methods for extracting Json-Values, and converting them into Java's "Boxed" types. "Boxed Types" are extremely easy to understand, and are just basic Java Primitive values - such as int, boolean or double that have been converted into a reference, and can be treated the same way that all reference values are treated and used in Java.
    Java's auto-boxing and un-boxing means that this process is extremely efficient, and owing to how the compiler has implemented boxed-primitives, there is next to no efficiency loss when using boxed primitives, rather than ordinary primitives.

    • Boxed primitives (such as java.lang.Integer and java.lang.Boolean) are reference types and may therefore hold the value null.
    • Boxed primitives may be used with Java generics and collections (for example, List<Integer>), whereas primitive types (such as int) may not.
    • Java supports automatic boxing and unboxing, allowing the compiler to transparently convert between a boxed value and its corresponding primitive value when required.


    Unlike ParseBoxedJSON, which operates on textual JsonString values, this class is intended for scenarios where numeric or boolean JSON values are already represented using native JSON types such as JsonNumber or JsonValue.TRUE. This distinction allows callers to choose the most direct and semantically appropriate conversion path based on how the source JSON data is structured, without forcing all values through an intermediate string representation.

    As with the other JSON reader classes in this package, each method operates on a single, explicitly addressed JSON value, either by array index or object property name. This design keeps data access predictable and makes it easier for calling code to distinguish between missing values, type mismatches, and valid conversions when integrating JSON input into strongly typed Java logic.



    Method Parameters

    Parameter Explanation
    ja A JsonArray whose element (at index) is being converted into a Java Boxed-Primitive value.

    For the numeric methods, the array-element is expected to be a JsonNumber. For the boolean methods, the array-element is expected to be JsonValue.TRUE or JsonValue.FALSE.

    If the element is JsonValue.NULL, these methods may return Java null (depending on the specific overload and/or flags).
    index The zero-based array index of the element being read from ja.

    When using a “no-flags” method, an out-of-bounds index will throw the normal Java exception.

    When using a FLAGS-overload, the flags may allow returning Java-null or a defaultValue rather than throwing.
    jo A JsonObject whose property value (named propertyName) is being converted into a Java Boxed-Primitive value.

    For the numeric methods, the property is expected to be a JsonNumber. For boolean methods, the property is expected to be JsonValue.TRUE or JsonValue.FALSE.

    If the property exists but contains JsonValue.NULL, these methods may return Java null (depending on the specific overload and/or flags).
    propertyName The name of the JsonObject property to retrieve from jo.

    If the property is not present and you are using a “no-flags” overload, behavior is controlled by isOptional.

    If the property is not present and you are using a FLAGS overload, the flags may allow returning Java-null or a defaultValue.
    isOptional Used by the “no-flags” JsonObject method overloads.

    When true and jo does not contain propertyName, the method returns Java-null.

    When false and the property is missing, an exception is thrown.

    Note: this parameter is about the property missing case. If the property exists but is JsonValue.NULL, the methods may still return Java null (the classes intentionally allow null-returns).
    FLAGS A bit-mask of JFlag constants that alters failure/edge-case behavior.

    When FLAGS is 0, the “normal” behavior applies (exceptions are thrown for missing property, wrong JSON type, arithmetic conversion failures, out-of-bounds index, etc.).

    When one or more flags are supplied, certain problems may be handled by returning Java-null or returning defaultValue instead of throwing.

    See the “Default-Value Flags” / “Flags Master List” documentation for the authoritative per-flag meaning in class JFlag
    defaultValue A Java <PRIMITIVE> fallback value that may be returned by the FLAGS-method overloads.

    If the selected flags request a “default-value return” for some failure/edge-case (missing property, null, wrong type, parse/arithmetic error, out-of-bounds, etc.), this is the value that will be returned.

    Note that the return type of the public methods is the corresponding Boxed Type (example: java.lang.Integer). The type of defaultValue is the matching primitive type. Java's "Auto-Boxing" and "Auto Un-Boxing" makes this easy.


    Single Character:
    Note that this class simply doesn't support any methods for reading a java.lang.Character. This is because their are just entirely too many possibilities, combinations & options for the appropriate "Default Behavior" when attempting to read a single character of data from any random JSON Data-Type.

    Remember that the JSON Specification does not posses any "Single-JSON-Character" Data-Type. Creating some kind of Flag-Controlled Reader for a 'char' that can capably decide what to do would be so overtly verbose, for something so simple, that it isn't worth the effort...
    See Also:
    JsonObject, JsonArray



    Stateless Class:
    This class neither contains any program-state, nor can it be instantiated. The @StaticFunctional Annotation may also be called 'The Spaghetti Report'. Static-Functional classes are, essentially, C-Styled Files, without any constructors or non-static member fields. It is a concept very similar to the Java-Bean's @Stateless Annotation.

    • 1 Constructor(s), 1 declared private, zero-argument constructor
    • 32 Method(s), 32 declared static
    • 0 Field(s)


    • Method Summary

       
      No Control Flags: Retrieve a JsonNumber from a JsonArray and Transform it to a Java Boxed Numeric Type
      Modifier and Type Method
      static Byte getByte​(JsonArray ja, int index)
      static Double getDouble​(JsonArray ja, int index)
      static Float getFloat​(JsonArray ja, int index)
      static Integer getInteger​(JsonArray ja, int index)
      static Long getLong​(JsonArray ja, int index)
      static Short getShort​(JsonArray ja, int index)
       
      No Control Flags: Retrieve a JsonNumber from a JsonObject and Transform it to a Java Boxed Numeric Type
      Modifier and Type Method
      static Byte getByte​(JsonObject jo, String propertyName, boolean isOptional)
      static Double getDouble​(JsonObject jo, String propertyName, boolean isOptional)
      static Float getFloat​(JsonObject jo, String propertyName, boolean isOptional)
      static Integer getInteger​(JsonObject jo, String propertyName, boolean isOptional)
      static Long getLong​(JsonObject jo, String propertyName, boolean isOptional)
      static Short getShort​(JsonObject jo, String propertyName, boolean isOptional)
       
      Using Error Control Flags: Retrieve a JsonNumber from a JsonArray and Transform it to a Java Boxed Numeric Type
      Modifier and Type Method
      static Byte getByte​(JsonArray ja, int index, int FLAGS, byte defaultValue)
      static Double getDouble​(JsonArray ja, int index, int FLAGS, double defaultValue)
      static Float getFloat​(JsonArray ja, int index, int FLAGS, float defaultValue)
      static Integer getInteger​(JsonArray ja, int index, int FLAGS, int defaultValue)
      static Long getLong​(JsonArray ja, int index, int FLAGS, long defaultValue)
      static Short getShort​(JsonArray ja, int index, int FLAGS, short defaultValue)
       
      Using Error Control Flags: Retrieve a JsonNumber from a JsonObject and Transform it to a Java Boxed Numeric Type
      Modifier and Type Method
      static Byte getByte​(JsonObject jo, String propertyName, int FLAGS, byte defaultValue)
      static Double getDouble​(JsonObject jo, String propertyName, int FLAGS, double defaultValue)
      static Float getFloat​(JsonObject jo, String propertyName, int FLAGS, float defaultValue)
      static Integer getInteger​(JsonObject jo, String propertyName, int FLAGS, int defaultValue)
      static Long getLong​(JsonObject jo, String propertyName, int FLAGS, long defaultValue)
      static Short getShort​(JsonObject jo, String propertyName, int FLAGS, short defaultValue)
       
      Boxed-Boolean Methods: Retrieve JsonValue.TRUE or FALSE and Transform it to a Java Boxed-Boolean
      Modifier and Type Method
      static Boolean getBoolean​(JsonArray ja, int index)
      static Boolean getBoolean​(JsonArray ja, int index, int FLAGS, boolean defaultValue)
      static Boolean getBoolean​(JsonObject jo, String propertyName, boolean isOptional)
      static Boolean getBoolean​(JsonObject jo, String propertyName, int FLAGS, boolean defaultValue)
       
      Internal Use Only, Protected: General Purpose Parse Methods
      Modifier and Type Method
      protected static <T extends Number>
      T
      GET​(JsonArray ja, int index, int FLAGS, T defaultValue, Class<T> returnClass, Function<JsonNumber,​T> jsonTypeToJavaType, Function<JsonNumber,​T> typeToType2)
      protected static <T extends Number>
      T
      GET​(JsonObject jo, String propertyName, int FLAGS, T defaultValue, Class<T> returnClass, Function<JsonNumber,​T> jsonTypeToJavaType, Function<JsonNumber,​T> typeToType2)
      protected static <T extends Number>
      T
      GET_NO_FLAGS​(JsonArray ja, int index, Function<JsonNumber,​T> jsonTypeToJavaType, Class<T> returnClass)
      protected static <T extends Number>
      T
      GET_NO_FLAGS​(JsonObject jo, String propertyName, boolean isOptional, Function<JsonNumber,​T> jsonTypeToJavaType, Class<T> returnClass)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getInteger

        🡇     🗕  🗗  🗖
        public static java.lang.Integer getInteger​(JsonArray ja,
                                                   int index)
        Retrieve a JsonArray element, and transform it to a Java Boxed Integer
        Accepts: a JsonArray, along with an array index.
        Flags: Does not accept user configuration flags. Instead, throws all default exceptions on error.
        Throws: Please review documentation for GET_NO_FLAGS method, listed below.
        Returns: A Java Boxed Integer (java.lang.Integer)
        See Also:
        GET_NO_FLAGS(JsonArray, int, Function, Class), JsonNumber.intValueExact()
        Code:
        Exact Method Body:
         return GET_NO_FLAGS(ja, index, JsonNumber::intValueExact, Integer.class);
        
      • getLong

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.Long getLong​(JsonArray ja,
                                             int index)
        Retrieve a JsonArray element, and transform it to a Boxed Long Integer
        Accepts: a JsonArray, along with an array index.
        Flags: Does not accept user configuration flags. Instead, throws all default exceptions on error.
        Throws: Please review documentation for GET_NO_FLAGS method, listed below.
        Returns: A Java Boxed Long (java.lang.Long)
        See Also:
        GET_NO_FLAGS(JsonArray, int, Function, Class), JsonNumber.longValueExact()
        Code:
        Exact Method Body:
         return GET_NO_FLAGS(ja, index, JsonNumber::longValueExact, Long.class);
        
      • getShort

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.Short getShort​(JsonArray ja,
                                               int index)
        Retrieve a JsonArray element, and transform it to a Boxed Short Integer
        Accepts: a JsonArray, along with an array index.
        Flags: Does not accept user configuration flags. Instead, throws all default exceptions on error.
        Throws: Please review documentation for GET_NO_FLAGS method, listed below.
        Returns: A Java Boxed Long (java.lang.Long)
        See Also:
        GET_NO_FLAGS(JsonArray, int, Function, Class), JsonNumber.bigDecimalValue()
        Code:
        Exact Method Body:
         return GET_NO_FLAGS(ja, index, jn -> jn.bigDecimalValue().shortValueExact(), Short.class);
        
      • getByte

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.Byte getByte​(JsonArray ja,
                                             int index)
        Retrieve a JsonArray element, and transform it to a Java Boxed Byte
        Accepts: a JsonArray, along with an array index.
        Flags: Does not accept user configuration flags. Instead, throws all default exceptions on error.
        Throws: Please review documentation for GET_NO_FLAGS method, listed below.
        Returns: A Java Boxed Byte (java.lang.Byte)
        See Also:
        GET_NO_FLAGS(JsonArray, int, Function, Class), JsonNumber.bigDecimalValue()
        Code:
        Exact Method Body:
         return GET_NO_FLAGS(ja, index, jn -> jn.bigDecimalValue().byteValueExact(), Byte.class);
        
      • getDouble

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.Double getDouble​(JsonArray ja,
                                                 int index)
        Retrieve a JsonArray element, and transform it to a Java Boxed Double
        Accepts: a JsonArray, along with an array index.
        Flags: Does not accept user configuration flags. Instead, throws all default exceptions on error.
        Throws: Please review documentation for GET_NO_FLAGS method, listed below.
        Returns: A Java Boxed Double (java.lang.Double)
        See Also:
        GET_NO_FLAGS(JsonArray, int, Function, Class), RJInternal.DOUBLE_WITH_CHECK(JsonNumber)
        Code:
        Exact Method Body:
         return GET_NO_FLAGS(ja, index, RJInternal::DOUBLE_WITH_CHECK, Double.class);
        
      • getFloat

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.Float getFloat​(JsonArray ja,
                                               int index)
        Retrieve a JsonArray element, and transform it to a Java Boxed Float
        Accepts: a JsonArray, along with an array index.
        Flags: Does not accept user configuration flags. Instead, throws all default exceptions on error.
        Throws: Please review documentation for GET_NO_FLAGS method, listed below.
        Returns: A Java Boxed Float (java.lang.Float)
        See Also:
        GET_NO_FLAGS(JsonArray, int, Function, Class), RJInternal.FLOAT_WITH_CHECK(JsonNumber)
        Code:
        Exact Method Body:
         return GET_NO_FLAGS(ja, index, RJInternal::FLOAT_WITH_CHECK, Float.class);
        
      • getBoolean

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.Boolean getBoolean​(JsonArray ja,
                                                   int index)
        Retrieve a JsonArray element, and transform it to a Java Boxed Boolean
        Accepts: a JsonArray, along with an array index.
        Flags: Does not accept user configuration flags. Instead, throws all default exceptions on error.
        Throws: Please review documentation for GET_NO_FLAGS method, listed below.
        Returns: A Java Boxed Boolean (java.lang.Boolean)
        See Also:
        JsonValue.getValueType(), JsonValue.ValueType.TRUE, JsonValue.ValueType.FALSE, JsonValue.TRUE, JsonValue.FALSE
        Code:
        Exact Method Body:
         final JsonValue jv = ja.get(index);
        
         switch (jv.getValueType())
         {
             case NULL:  return null;
             case TRUE:  return true;
             case FALSE: return false;
             default:    throw new JsonTypeArrException(ja, index, TRUE, jv, Boolean.class);
         }
        
      • getInteger

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.Integer getInteger​(JsonObject jo,
                                                   java.lang.String propertyName,
                                                   boolean isOptional)
        Retrieve a JsonObject property, and transform it to a Java Boxed Integer
        Accepts: a JsonObject, along with property name, as a java.lang.String
        Flags: Does not accept user configuration flags. Instead, throws all default exceptions on error.
        Throws: Please review documentation for GET_NO_FLAGS method, listed below.
        Returns: A Java Boxed Integer (java.lang.Integer)
        See Also:
        GET_NO_FLAGS(JsonObject, String, boolean, Function, Class), JsonNumber.intValueExact()
        Code:
        Exact Method Body:
         return GET_NO_FLAGS
             (jo, propertyName, isOptional, JsonNumber::intValueExact, Integer.class);
        
      • getLong

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.Long getLong​(JsonObject jo,
                                             java.lang.String propertyName,
                                             boolean isOptional)
        Retrieve a JsonObject property, and transform it to a Boxed Long Integer
        Accepts: a JsonObject, along with property name, as a java.lang.String
        Flags: Does not accept user configuration flags. Instead, throws all default exceptions on error.
        Throws: Please review documentation for GET_NO_FLAGS method, listed below.
        Returns: A Java Boxed Long (java.lang.Long)
        See Also:
        GET_NO_FLAGS(JsonObject, String, boolean, Function, Class), JsonNumber.longValueExact()
        Code:
        Exact Method Body:
         return GET_NO_FLAGS
             (jo, propertyName, isOptional, JsonNumber::longValueExact, Long.class);
        
      • getShort

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.Short getShort​(JsonObject jo,
                                               java.lang.String propertyName,
                                               boolean isOptional)
        Retrieve a JsonObject property, and transform it to a Boxed Short Integer
        Accepts: a JsonObject, along with property name, as a java.lang.String
        Flags: Does not accept user configuration flags. Instead, throws all default exceptions on error.
        Throws: Please review documentation for GET_NO_FLAGS method, listed below.
        Returns: A Java Boxed Short (java.lang.Short)
        See Also:
        GET_NO_FLAGS(JsonObject, String, boolean, Function, Class), JsonNumber.bigDecimalValue()
        Code:
        Exact Method Body:
         return GET_NO_FLAGS(
             jo, propertyName, isOptional,
             jn -> jn.bigDecimalValue().shortValueExact(),
             Short.class
         );
        
      • getByte

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.Byte getByte​(JsonObject jo,
                                             java.lang.String propertyName,
                                             boolean isOptional)
        Retrieve a JsonObject property, and transform it to a Java Boxed Byte
        Accepts: a JsonObject, along with property name, as a java.lang.String
        Flags: Does not accept user configuration flags. Instead, throws all default exceptions on error.
        Throws: Please review documentation for GET_NO_FLAGS method, listed below.
        Returns: A Java Boxed Byte (java.lang.Byte)
        See Also:
        GET_NO_FLAGS(JsonObject, String, boolean, Function, Class), JsonNumber.bigDecimalValue()
        Code:
        Exact Method Body:
         return GET_NO_FLAGS(
             jo, propertyName, isOptional,
             jn -> jn.bigDecimalValue().byteValueExact(),
             Byte.class
         );
        
      • getDouble

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.Double getDouble​(JsonObject jo,
                                                 java.lang.String propertyName,
                                                 boolean isOptional)
        Retrieve a JsonObject property, and transform it to a Java Boxed Double
        Accepts: a JsonObject, along with property name, as a java.lang.String
        Flags: Does not accept user configuration flags. Instead, throws all default exceptions on error.
        Throws: Please review documentation for GET_NO_FLAGS method, listed below.
        Returns: A Java Boxed Double (java.lang.Double)
        See Also:
        GET_NO_FLAGS(JsonObject, String, boolean, Function, Class), RJInternal.DOUBLE_WITH_CHECK(JsonNumber)
        Code:
        Exact Method Body:
         return GET_NO_FLAGS
             (jo, propertyName, isOptional, RJInternal::DOUBLE_WITH_CHECK, Double.class);
        
      • getFloat

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.Float getFloat​(JsonObject jo,
                                               java.lang.String propertyName,
                                               boolean isOptional)
        Retrieve a JsonObject property, and transform it to a Java Boxed Float
        Accepts: a JsonObject, along with property name, as a java.lang.String
        Flags: Does not accept user configuration flags. Instead, throws all default exceptions on error.
        Throws: Please review documentation for GET_NO_FLAGS method, listed below.
        Returns: A Java Boxed Float (java.lang.Float)
        See Also:
        GET_NO_FLAGS(JsonObject, String, boolean, Function, Class), RJInternal.FLOAT_WITH_CHECK(JsonNumber)
        Code:
        Exact Method Body:
         return GET_NO_FLAGS
             (jo, propertyName, isOptional, RJInternal::FLOAT_WITH_CHECK, Float.class);
        
      • getBoolean

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.Boolean getBoolean​(JsonObject jo,
                                                   java.lang.String propertyName,
                                                   boolean isOptional)
        Retrieve a JsonObject property, and transform it to a Java Boxed Boolean
        Accepts: a JsonObject, along with property name, as a java.lang.String
        Flags: Does not accept user configuration flags. Instead, throws all default exceptions on error.
        Throws: Please review documentation for GET_NO_FLAGS method, listed below.
        Returns: A Java Boxed Boolean (java.lang.Boolean)
        See Also:
        JsonValue.getValueType(), JsonValue.ValueType.TRUE, JsonValue.ValueType.FALSE, JsonValue.TRUE, JsonValue.FALSE
        Code:
        Exact Method Body:
         if (! jo.containsKey(propertyName))
         {
             if (isOptional) return null;
             throw new JsonPropMissingException(jo, propertyName, TRUE, Boolean.class);
         }
        
         final JsonValue jv = jo.get(propertyName);
        
         switch (jv.getValueType())
         {
             case NULL:  return null;
             case TRUE:  return true;
             case FALSE: return false;
             default:    throw new JsonTypeObjException(jo, propertyName, TRUE, jv, Boolean.class);
         }
        
      • getShort

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.Short getShort​(JsonArray ja,
                                               int index,
                                               int FLAGS,
                                               short defaultValue)
        Retrieve a JsonArray element, and transform it to a Boxed Short Integer
        Accepts: a JsonArray, along with an array index.
        Flags: Accepts Error-Control Flags; May be configured to suppress exceptions.
        Throws: Please review documentation for GET method, listed below.
        Returns: A Java Boxed Short (java.lang.Short)
        See Also:
        GET(JsonArray, int, int, Number, Class, Function, Function), JsonNumber.bigDecimalValue()
        Code:
        Exact Method Body:
         return GET(
             ja, index, FLAGS, defaultValue, Short.class,
             jn -> jn.bigDecimalValue().shortValueExact(),
             jn -> jn.bigDecimalValue().shortValue()
         );
        
      • getByte

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.Byte getByte​(JsonArray ja,
                                             int index,
                                             int FLAGS,
                                             byte defaultValue)
        Retrieve a JsonArray element, and transform it to a Java Boxed Byte
        Accepts: a JsonArray, along with an array index.
        Flags: Accepts Error-Control Flags; May be configured to suppress exceptions.
        Throws: Please review documentation for GET method, listed below.
        Returns: A Java Boxed Byte (java.lang.Byte)
        See Also:
        GET(JsonArray, int, int, Number, Class, Function, Function), JsonNumber.bigDecimalValue()
        Code:
        Exact Method Body:
         return GET(
             ja, index, FLAGS, defaultValue, Byte.class,
             jn -> jn.bigDecimalValue().byteValueExact(),
             jn -> jn.bigDecimalValue().byteValue()
         );
        
      • getBoolean

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.Boolean getBoolean​(JsonArray ja,
                                                   int index,
                                                   int FLAGS,
                                                   boolean defaultValue)
        Retrieve a JsonArray element, and transform it to a Java Boxed Boolean
        Accepts: a JsonArray, along with an array index.
        Flags: Accepts Error-Control Flags; May be configured to suppress exceptions.
        Throws: Please review documentation for GET method, listed below.
        Returns: A Java Boxed Boolean (java.lang.Boolean)
        See Also:
        JsonValue.getValueType(), JsonValue.ValueType.TRUE, JsonValue.ValueType.FALSE, JsonValue.TRUE, JsonValue.FALSE
        Code:
        Exact Method Body:
         if (index >= ja.size()) return IOOBEX(ja, index, defaultValue, FLAGS);
        
         final JsonValue jv = ja.get(index); // Throw an IndexOutOfBoundsException
        
         switch (jv.getValueType())
         {
             case NULL:  return JNAEX(ja, index, defaultValue, FLAGS, TRUE, Boolean.class);
             case TRUE:  return true;
             case FALSE: return false;
             default:    return JTAEX(ja, index, defaultValue, FLAGS, TRUE, jv, Boolean.class);
         }
        
      • getInteger

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.Integer getInteger​(JsonObject jo,
                                                   java.lang.String propertyName,
                                                   int FLAGS,
                                                   int defaultValue)
        Retrieve a JsonObject property, and transform it to a Java Boxed Integer
        Accepts: a JsonObject, along with property name, as a java.lang.String
        Flags: Accepts Error-Control Flags; May be configured to suppress exceptions.
        Throws: Please review documentation for GET method, listed below.
        Returns: A Java Boxed Integer (java.lang.Integer)
        See Also:
        GET(JsonObject, String, int, Number, Class, Function, Function), JsonNumber.intValueExact(), JsonNumber.intValue()
        Code:
        Exact Method Body:
         return GET(
             jo, propertyName, FLAGS, defaultValue,
             Integer.class, JsonNumber::intValueExact, JsonNumber::intValue
         );
        
      • getShort

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.Short getShort​(JsonObject jo,
                                               java.lang.String propertyName,
                                               int FLAGS,
                                               short defaultValue)
        Retrieve a JsonObject property, and transform it to a Boxed Short Integer
        Accepts: a JsonObject, along with property name, as a java.lang.String
        Flags: Accepts Error-Control Flags; May be configured to suppress exceptions.
        Throws: Please review documentation for GET method, listed below.
        Returns: A Java Boxed Short (java.lang.Short)
        See Also:
        GET(JsonObject, String, int, Number, Class, Function, Function), JsonNumber.bigDecimalValue()
        Code:
        Exact Method Body:
         return GET(
             jo, propertyName, FLAGS, defaultValue,
             Short.class,
             jn -> jn.bigDecimalValue().shortValueExact(),
             jn -> jn.bigDecimalValue().shortValue()
         );
        
      • getByte

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.Byte getByte​(JsonObject jo,
                                             java.lang.String propertyName,
                                             int FLAGS,
                                             byte defaultValue)
        Retrieve a JsonObject property, and transform it to a Java Boxed Byte
        Accepts: a JsonObject, along with property name, as a java.lang.String
        Flags: Accepts Error-Control Flags; May be configured to suppress exceptions.
        Throws: Please review documentation for GET method, listed below.
        Returns: A Java Boxed Byte (java.lang.Byte)
        See Also:
        GET(JsonObject, String, int, Number, Class, Function, Function), JsonNumber.bigDecimalValue()
        Code:
        Exact Method Body:
         return GET(
             jo, propertyName, FLAGS, defaultValue,
             Byte.class,
             jn -> jn.bigDecimalValue().byteValueExact(),
             jn -> jn.bigDecimalValue().byteValue()
         );
        
      • getBoolean

        🡅  🡇     🗕  🗗  🗖
        public static java.lang.Boolean getBoolean​(JsonObject jo,
                                                   java.lang.String propertyName,
                                                   int FLAGS,
                                                   boolean defaultValue)
        Retrieve a JsonObject property, and transform it to a Java Boxed Boolean
        Accepts: a JsonObject, along with property name, as a java.lang.String
        Flags: Accepts Error-Control Flags; May be configured to suppress exceptions.
        Throws: Please review documentation for GET method, listed below.
        Returns: A Java Boxed Boolean (java.lang.Boolean)
        See Also:
        JsonValue.getValueType(), JsonValue.ValueType.TRUE, JsonValue.ValueType.FALSE, JsonValue.TRUE, JsonValue.FALSE
        Code:
        Exact Method Body:
         final JsonValue jv = jo.get(propertyName);
        
         if (jv == null) return JPMEX(jo, propertyName, defaultValue, FLAGS, TRUE, Boolean.class);
        
         switch (jv.getValueType())
         {
             case NULL:  return JNOEX(jo, propertyName, defaultValue, FLAGS, TRUE, Boolean.class);
             case TRUE:  return true;
             case FALSE: return false;
        
             default:
                 return JTOEX(jo, propertyName, defaultValue, FLAGS, TRUE, jv, Boolean.class);
         }
        
      • GET_NO_FLAGS

        🡅  🡇     🗕  🗗  🗖
        protected static <T extends java.lang.Number> T GET_NO_FLAGS​
                    (JsonArray ja,
                     int index,
                     java.util.function.Function<JsonNumber,​T> jsonTypeToJavaType,
                     java.lang.Class<T> returnClass)
        
        This is an internal helper method for retrieving an element from a JsonArray, and converting it to one of the standard Java Types.
        Type Parameters:
        T - Numeric Boxed-Type, as an instance of java.lang.Class
        Parameters:
        ja - Any instance of JsonArray
        index - A valid index into 'ja'
        jsonTypeToJavaType - This should convert an instance of JsonNumber, into one of the concrete, boxed, subclasses of java.lang.Number
        Returns:
        The converted number, as an instance Generic-Parameter 'T'
        Throws:
        JsonTypeArrException - If array index specified does not contain a JsonNumber
        JsonArithmeticArrException - If there any arithmetic problems during the conversion
        java.lang.IndexOutOfBoundsException - If 'index' is out of the bounds of 'ja'
        See Also:
        getInteger(JsonArray, int), getLong(JsonArray, int), getShort(JsonArray, int), getByte(JsonArray, int), getDouble(JsonArray, int), getFloat(JsonArray, int)
        Code:
        Exact Method Body:
         // This will throw an IndexOutOfBoundsException if the index is out of bounds.
         // Since this *IS NOT* a method with FLAGS, the user has no way to avoid this exception
         // throw if, indeed, the index really is out of bounds!
         //
         // Using one of the 'FLAGS' variants of the 'GET' array-index, a user may request that
         // either null or a default-value be returned.  Not with this version-of 'GET', though.
        
         final JsonValue jv = ja.get(index);
        
         switch (jv.getValueType())
         {
             // This method allows for null-returns.  If Json-Null, return Java-Null.
             case NULL: return null;
        
             // This will throw ArithmeticException if it cannot be converted
             case NUMBER:
        
                 // REMEMBER: The primary reason for this class is that MEANINGFUL ERROR MESSAGES
                 //           make Json-Binding a lot easer...  "JsonArithmeticException" has just
                 //           about everything that you need to know when debugging this stuff
        
                 try
                     { return jsonTypeToJavaType.apply((JsonNumber) jv); }
        
                 catch (ArithmeticException ae)
                 {
                     throw new JsonArithmeticArrException
                         (ae, ja, index, NUMBER, jv, returnClass);
                 }
        
             // The JsonValue at the specified array-index does not contain an JsonNumber.
             default: throw new JsonTypeArrException
                 (ja, index, NUMBER, jv, returnClass);
         }
        
      • GET_NO_FLAGS

        🡅  🡇     🗕  🗗  🗖
        protected static <T extends java.lang.Number> T GET_NO_FLAGS​
                    (JsonObject jo,
                     java.lang.String propertyName,
                     boolean isOptional,
                     java.util.function.Function<JsonNumber,​T> jsonTypeToJavaType,
                     java.lang.Class<T> returnClass)
        
        This is an internal helper method for retrieving a property from a JsonObject, and converting it to one of the standard Java Types.
        Type Parameters:
        T - Numeric Boxed-Type, as an instance of java.lang.Class
        Parameters:
        jo - Any instance of JsonObject
        propertyName - Any property name contained by 'jo'
        isOptional - When TRUE is passed, if 'propertyName' is not actually listed in 'jo' this method shall return Java-Null gracefully. When FALSE is passed, if 'jo' does not have the specified property, a JsonPropMissingException will throw.

        If 'jo' actually has a property named 'propertyName', then the value passed to this parameter is fully irrelevant.
        jsonTypeToJavaType - This should convert an instance of JsonNumber, into one of the concrete, boxed, subclasses of java.lang.Number
        Returns:
        The converted number, as an instance of Generic-Parameter 'T'
        Throws:
        JsonPropMissingException - If the property is missing, and 'isOptional' is FALSE.
        JsonTypeObjException - If the property specified does not contain a JsonNumber
        JsonArithmeticObjException - If there any arithmetic problems during the conversion
        See Also:
        getInteger(JsonObject, String, boolean), getLong(JsonObject, String, boolean), getShort(JsonObject, String, boolean), getByte(JsonObject, String, boolean), getDouble(JsonObject, String, boolean), getFloat(JsonObject, String, boolean)
        Code:
        Exact Method Body:
         // Here, a 'get' request was made for a property that isn't actually listed among the
         // properties in the provided JsonObject.  If 'isOptional' return null, otherwise throw
        
         if (! jo.containsKey(propertyName))
         {
             if (isOptional) return null;
        
             throw new JsonPropMissingException
                 (jo, propertyName, NUMBER, returnClass);
         }
        
         final JsonValue jv = jo.get(propertyName);
        
         switch (jv.getValueType())
         {
             // This method allows for null-returns.  If Json-Null, return Java-Null.
             case NULL: return null;
        
             // This will throw ArithmeticException if this isn't a proper Java int
             case NUMBER:
        
        
                 // REMEMBER: The primary reason for this class is that MEANINGFUL ERROR MESSAGES
                 //           make Json-Binding a lot easer...  "JsonArithmeticException" has just
                 //           about everything that you need to know when debugging this stuff
        
                 try
                     { return jsonTypeToJavaType.apply((JsonNumber) jv); }
        
                 catch (ArithmeticException ae)
                 {
                     throw new JsonArithmeticObjException
                         (ae, jo, propertyName, NUMBER, jv, returnClass);
                 }
        
             // The JsonObject property does not contain a JsonNumber.
             default: throw new JsonTypeObjException
                 (jo, propertyName, NUMBER, jv, returnClass);
         }