Class ReadPrimJSON


  • public class ReadPrimJSON
    extends java.lang.Object
    JSON Binding Helper-Class:
    JSON-Binding is the art of converting data that has been stored, saved or transmitted using Java-Script Object Notation into a Primitive-Type or Object-Type of any Programming Language, for instance Java. JSON often arrives into Java-Program Memory from an external Internet Connection, and may have traveled hundreds or even thousands of miles from a Host-Server.

    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 is never completely assured.

    Being able to handle changes that might be made to an API (possibly from great distances away, and without the Software-Manager's consent) is the type of feature that robust JSON-Code simply has to offer.

    Binding-Helper Features:
    • 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
    • Primary Helper-Classes for the (Experimental) Google-Chrome Headless Browser Package
    Builds on the J2EE Standard Release JSON Parsing Tools by providing additional help with converting JSON Data into Java 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 tool included in the J2EE is available on GitHub, and that is the one used by the Java HTML JAR Library. (See: javax.json.* )

    Primary Classes Used: JsonArray and JsonObject


    Note that this class simply doesn't support any methods for reading a char. 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:
    Json, 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
    • 14 Method(s), 14 declared static
    • 0 Field(s)


    • Method Summary

       
      int: Retrieve a JsonNumber and transform it to a Java 'int' Primitive
      Modifier and Type Method
      static int getInt​(JsonArray ja, int index)
      static int getInt​(JsonObject jo, String propertyName)
       
      long: Retrieve a JsonNumber and transform it to a Java 'long' Primitive
      Modifier and Type Method
      static long getLong​(JsonArray ja, int index)
      static long getLong​(JsonObject jo, String propertyName)
       
      short: Retrieve a JsonNumber and transform it to a Java 'short' Primitive
      Modifier and Type Method
      static short getShort​(JsonArray ja, int index)
      static short getShort​(JsonObject jo, String propertyName)
       
      byte: Retrieve a JsonNumber and transform it to a Java 'byte' Primitive
      Modifier and Type Method
      static byte getByte​(JsonArray ja, int index)
      static byte getByte​(JsonObject jo, String propertyName)
       
      double: Retrieve a JsonNumber and transform it to a Java 'double' Primitive
      Modifier and Type Method
      static double getDouble​(JsonArray ja, int index)
      static double getDouble​(JsonObject jo, String propertyName)
       
      float: Retrieve a JsonNumber and transform it to a Java 'float' Primitive
      Modifier and Type Method
      static float getFloat​(JsonArray ja, int index)
      static float getFloat​(JsonObject jo, String propertyName)
       
      boolean: Retrieve JsonValue.TRUE or FALSE, and transform it to a Java 'boolean' Primitive
      Modifier and Type Method
      static boolean getBoolean​(JsonArray ja, int index)
      static boolean getBoolean​(JsonObject jo, String propertyName)
      • Methods inherited from class java.lang.Object

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

      • getInt

        🡇     🗕  🗗  🗖
        public static int getInt​(JsonArray ja,
                                 int index)
        Retrieve a JsonArray element, and transform it to an 'int' primitive
        Parameters:
        ja - Any instance of JsonArray
        index - A valid index into array parameter 'ja'. In Json (and unlike Java), array element types are not actually checked for consistency - meaning an array may hold many different types! This array-index must contain a JsonNumber
        Returns:
        An instance of Java-Type int, if and only if the array element located at 'index' uses the appropriate Json-Type - JsonNumber, and that element may be properly mapped to a Java int.
        Throws:
        java.lang.IndexOutOfBoundsException - If 'index' is out of the bounds of 'ja'
        JsonTypeArrException - If the array-element (specified by 'index') does not actually contain a JsonNumber (but rather, some other non-null Json-Type), then this exception throws.
        JsonArithmeticArrException - Java's implementation of intValueExact() throws an ArithmeticException when that method cannot correctly transform / convert the element to a valid int. The thrown-exception is then wrapped into this exception for the purpose of providing a much improved error-message, and convenience fields.
        JsonNullPrimitiveArrException - If 'index' specifies an element inside 'ja' that has been assigned Json-Null, then this exception will throw. (Unlike Json, in Java a Primitive int will not accept 'null' as a value).
        See Also:
        RJInternal.GET(JsonArray, int, Class, Function), JsonNumber.intValueExact()
        Code:
        Exact Method Body:
         return GET(ja, index, int.class, JsonNumber::intValueExact);
        
      • getInt

        🡅  🡇     🗕  🗗  🗖
        public static int getInt​(JsonObject jo,
                                 java.lang.String propertyName)
        Extract a JsonObject property, and transform it to an 'int' primitive
        Parameters:
        jo - Any instance of JsonObject
        propertyName - The name of the JSON property that should be contained within 'jo'. This property will be retrieved and subsequently transformed / converted to Java-Type int.
        Returns:
        An instance of Java-Type int, if and only if the 'propertyName' is available inside 'jo', and that property uses the appropriate Json-Type - JsonNumber. Furthermore, that JsonNumber must be assignable to Java Primitive Type int, or this method will throw an exception.
        Throws:
        JsonPropMissingException - This exception throws if the JsonObject (parameter 'jo') does not have any properties with the name 'propertyName'.
        JsonArithmeticObjException - Java's implementation of intValueExact() throws an ArithmeticException when that method cannot correctly transform / convert the element to a valid int. The thrown-exception is then wrapped into this exception for the purpose of providing a much improved error-message, and convenience fields.
        JsonTypeObjException - If the property (specified by 'propertyName') is extracted, but that property does not actually contain a JsonNumber (but rather, some other non-null Json-Type), then this exception throws.
        JsonNullPrimitiveObjException - If 'propertyName' specifies a property inside 'jo' that has been assigned Json-Null, then this exception will throw. (Unlike Json, in Java a Primitive int will not accept 'null' as a value).
        See Also:
        RJInternal.GET(JsonObject, String, Class, Function), JsonNumber.intValueExact()
        Code:
        Exact Method Body:
         return GET(jo, propertyName, int.class, JsonNumber::intValueExact);
        
      • getLong

        🡅  🡇     🗕  🗗  🗖
        public static long getLong​(JsonArray ja,
                                   int index)
        Retrieve a JsonArray element, and transform it to a 'long' primitive
        Parameters:
        ja - Any instance of JsonArray
        index - A valid index into array parameter 'ja'. In Json (and unlike Java), array element types are not actually checked for consistency - meaning an array may hold many different types! This array-index must contain a JsonNumber
        Returns:
        An instance of Java-Type long, if and only if the array element located at 'index' uses the appropriate Json-Type - JsonNumber, and that element may be properly mapped to a Java long.
        Throws:
        java.lang.IndexOutOfBoundsException - If 'index' is out of the bounds of 'ja'
        JsonTypeArrException - If the array-element (specified by 'index') does not actually contain a JsonNumber (but rather, some other non-null Json-Type), then this exception throws.
        JsonArithmeticArrException - Java's implementation of longValueExact() throws an ArithmeticException when that method cannot correctly transform / convert the element to a valid long. The thrown-exception is then wrapped into this exception for the purpose of providing a much improved error-message, and convenience fields.
        JsonNullPrimitiveArrException - If 'index' specifies an element inside 'ja' that has been assigned Json-Null, then this exception will throw. (Unlike Json, in Java a Primitive long will not accept 'null' as a value).
        See Also:
        RJInternal.GET(JsonArray, int, Class, Function), JsonNumber.longValueExact()
        Code:
        Exact Method Body:
         return GET(ja, index, long.class, JsonNumber::longValueExact);
        
      • getLong

        🡅  🡇     🗕  🗗  🗖
        public static long getLong​(JsonObject jo,
                                   java.lang.String propertyName)
        Extract a JsonObject property, and transform it to a 'long' primitive
        Parameters:
        jo - Any instance of JsonObject
        propertyName - The name of the JSON property that should be contained within 'jo'. This property will be retrieved and subsequently transformed / converted to Java-Type long.
        Returns:
        An instance of Java-Type long, if and only if the 'propertyName' is available inside 'jo', and that property uses the appropriate Json-Type - JsonNumber. Furthermore, that JsonNumber must be assignable to Java Primitive Type long, or this method will throw an exception.
        Throws:
        JsonPropMissingException - This exception throws if the JsonObject (parameter 'jo') does not have any properties with the name 'propertyName'.
        JsonArithmeticObjException - Java's implementation of longValueExact() throws an ArithmeticException when that method cannot correctly transform / convert the element to a valid long. The thrown-exception is then wrapped into this exception for the purpose of providing a much improved error-message, and convenience fields.
        JsonTypeObjException - If the property (specified by 'propertyName') is extracted, but that property does not actually contain a JsonNumber (but rather, some other non-null Json-Type), then this exception throws.
        JsonNullPrimitiveObjException - If 'propertyName' specifies a property inside 'jo' that has been assigned Json-Null, then this exception will throw. (Unlike Json, in Java a Primitive long will not accept 'null' as a value).
        See Also:
        RJInternal.GET(JsonObject, String, Class, Function), JsonNumber.longValueExact()
        Code:
        Exact Method Body:
         return GET(jo, propertyName, long.class, JsonNumber::longValueExact);
        
      • getShort

        🡅  🡇     🗕  🗗  🗖
        public static short getShort​(JsonArray ja,
                                     int index)
        Retrieve a JsonArray element, and transform it to a 'short' primitive
        Parameters:
        ja - Any instance of JsonArray
        index - A valid index into array parameter 'ja'. In Json (and unlike Java), array element types are not actually checked for consistency - meaning an array may hold many different types! This array-index must contain a JsonNumber
        Returns:
        An instance of Java-Type short, if and only if the array element located at 'index' uses the appropriate Json-Type - JsonNumber, and that element may be properly mapped to a Java short.
        Throws:
        java.lang.IndexOutOfBoundsException - If 'index' is out of the bounds of 'ja'
        JsonTypeArrException - If the array-element (specified by 'index') does not actually contain a JsonNumber (but rather, some other non-null Json-Type), then this exception throws.
        JsonArithmeticArrException - Java's implementation of shortValueExact() throws an ArithmeticException when that method cannot correctly transform / convert the element to a valid short. The thrown-exception is then wrapped into this exception for the purpose of providing a much improved error-message, and convenience fields.
        JsonNullPrimitiveArrException - If 'index' specifies an element inside 'ja' that has been assigned Json-Null, then this exception will throw. (Unlike Json, in Java a Primitive short will not accept 'null' as a value).
        See Also:
        RJInternal.GET(JsonArray, int, Class, Function), JsonNumber.bigDecimalValue()
        Code:
        Exact Method Body:
         return GET(ja, index, short.class, jn -> jn.bigDecimalValue().shortValueExact());
        
      • getShort

        🡅  🡇     🗕  🗗  🗖
        public static short getShort​(JsonObject jo,
                                     java.lang.String propertyName)
        Extract a JsonObject property, and transform it to a 'short' primitive
        Parameters:
        jo - Any instance of JsonObject
        propertyName - The name of the JSON property that should be contained within 'jo'. This property will be retrieved and subsequently transformed / converted to Java-Type short.
        Returns:
        An instance of Java-Type short, if and only if the 'propertyName' is available inside 'jo', and that property uses the appropriate Json-Type - JsonNumber. Furthermore, that JsonNumber must be assignable to Java Primitive Type short, or this method will throw an exception.
        Throws:
        JsonPropMissingException - This exception throws if the JsonObject (parameter 'jo') does not have any properties with the name 'propertyName'.
        JsonArithmeticObjException - Java's implementation of shortValueExact() throws an ArithmeticException when that method cannot correctly transform / convert the element to a valid short. The thrown-exception is then wrapped into this exception for the purpose of providing a much improved error-message, and convenience fields.
        JsonTypeObjException - If the property (specified by 'propertyName') is extracted, but that property does not actually contain a JsonNumber (but rather, some other non-null Json-Type), then this exception throws.
        JsonNullPrimitiveObjException - If 'propertyName' specifies a property inside 'jo' that has been assigned Json-Null, then this exception will throw. (Unlike Json, in Java a Primitive short will not accept 'null' as a value).
        See Also:
        RJInternal.GET(JsonObject, String, Class, Function), JsonNumber.bigDecimalValue()
        Code:
        Exact Method Body:
         return GET(jo, propertyName, short.class, jn -> jn.bigDecimalValue().shortValueExact());
        
      • getByte

        🡅  🡇     🗕  🗗  🗖
        public static byte getByte​(JsonArray ja,
                                   int index)
        Retrieve a JsonArray element, and transform it to a 'byte' primitive
        Parameters:
        ja - Any instance of JsonArray
        index - A valid index into array parameter 'ja'. In Json (and unlike Java), array element types are not actually checked for consistency - meaning an array may hold many different types! This array-index must contain a JsonNumber
        Returns:
        An instance of Java-Type byte, if and only if the array element located at 'index' uses the appropriate Json-Type - JsonNumber, and that element may be properly mapped to a Java byte.
        Throws:
        java.lang.IndexOutOfBoundsException - If 'index' is out of the bounds of 'ja'
        JsonTypeArrException - If the array-element (specified by 'index') does not actually contain a JsonNumber (but rather, some other non-null Json-Type), then this exception throws.
        JsonArithmeticArrException - Java's implementation of byteValueExact() throws an ArithmeticException when that method cannot correctly transform / convert the element to a valid byte. The thrown-exception is then wrapped into this exception for the purpose of providing a much improved error-message, and convenience fields.
        JsonNullPrimitiveArrException - If 'index' specifies an element inside 'ja' that has been assigned Json-Null, then this exception will throw. (Unlike Json, in Java a Primitive byte will not accept 'null' as a value).
        See Also:
        RJInternal.GET(JsonArray, int, Class, Function), JsonNumber.bigDecimalValue()
        Code:
        Exact Method Body:
         return GET(ja, index, byte.class, jn -> jn.bigDecimalValue().byteValueExact());
        
      • getByte

        🡅  🡇     🗕  🗗  🗖
        public static byte getByte​(JsonObject jo,
                                   java.lang.String propertyName)
        Extract a JsonObject property, and transform it to a 'byte' primitive
        Parameters:
        jo - Any instance of JsonObject
        propertyName - The name of the JSON property that should be contained within 'jo'. This property will be retrieved and subsequently transformed / converted to Java-Type byte.
        Returns:
        An instance of Java-Type byte, if and only if the 'propertyName' is available inside 'jo', and that property uses the appropriate Json-Type - JsonNumber. Furthermore, that JsonNumber must be assignable to Java Primitive Type byte, or this method will throw an exception.
        Throws:
        JsonPropMissingException - This exception throws if the JsonObject (parameter 'jo') does not have any properties with the name 'propertyName'.
        JsonArithmeticObjException - Java's implementation of byteValueExact() throws an ArithmeticException when that method cannot correctly transform / convert the element to a valid byte. The thrown-exception is then wrapped into this exception for the purpose of providing a much improved error-message, and convenience fields.
        JsonTypeObjException - If the property (specified by 'propertyName') is extracted, but that property does not actually contain a JsonNumber (but rather, some other non-null Json-Type), then this exception throws.
        JsonNullPrimitiveObjException - If 'propertyName' specifies a property inside 'jo' that has been assigned Json-Null, then this exception will throw. (Unlike Json, in Java a Primitive byte will not accept 'null' as a value).
        See Also:
        RJInternal.GET(JsonObject, String, Class, Function), JsonNumber.bigDecimalValue()
        Code:
        Exact Method Body:
         return GET(jo, propertyName, byte.class, jn -> jn.bigDecimalValue().byteValueExact());
        
      • getDouble

        🡅  🡇     🗕  🗗  🗖
        public static double getDouble​(JsonArray ja,
                                       int index)
        Retrieve a JsonArray element, and transform it to a 'double' primitive

        NOTE: If the precision of the provided JsonNumber contains too much information, the extra digits will simply be lost; no exceptions will throw; and the method shall return a rounded answer - gracefully.

        If the magnitude of the number is too large or too small, an ArithmeticException will throw, as explained below.
        Parameters:
        ja - Any instance of JsonArray
        index - A valid index into array parameter 'ja'. In Json (and unlike Java), array element types are not actually checked for consistency - meaning an array may hold many different types! This array-index must contain a JsonNumber
        Returns:
        An instance of Java-Type double, if and only if the array element located at 'index' uses the appropriate Json-Type - JsonNumber, and that element may be properly mapped to a Java double.
        Throws:
        java.lang.IndexOutOfBoundsException - If 'index' is out of the bounds of 'ja'
        JsonTypeArrException - If the array-element (specified by 'index') does not actually contain a JsonNumber (but rather, some other non-null Json-Type), then this exception throws.
        JsonArithmeticArrException - Java's implementation of BigDecimal.doubleValue() will return an infinity constant (Double.NEGATIVE_INFINITY or Double.POSITIVE_INFINITY) when the magnitude of the returned value is too large to fit inside the Java Type double.

        This method checks for the infinity constants, and then proceeds to throw this exception when they are detected.
        JsonNullPrimitiveArrException - If 'index' specifies an element inside 'ja' that has been assigned Json-Null, then this exception will throw. (Unlike Json, in Java a Primitive double will not accept 'null' as a value).
        See Also:
        RJInternal.GET(JsonArray, int, Class, Function), RJInternal.DOUBLE_WITH_CHECK(JsonNumber)
        Code:
        Exact Method Body:
         return GET(ja, index, double.class, RJInternal::DOUBLE_WITH_CHECK);
        
      • getDouble

        🡅  🡇     🗕  🗗  🗖
        public static double getDouble​(JsonObject jo,
                                       java.lang.String propertyName)
        Extract a JsonObject property, and transform it to a 'double' primitive

        NOTE: If the precision of the provided JsonNumber contains too much information, the extra digits will simply be lost; no exceptions will throw; and the method shall return a rounded answer - gracefully.

        If the magnitude of the number is too large or too small, an ArithmeticException will throw, as explained below.
        Parameters:
        jo - Any instance of JsonObject
        propertyName - The name of the JSON property that should be contained within 'jo'. This property will be retrieved and subsequently transformed / converted to Java-Type double.
        Returns:
        An instance of Java-Type double, if and only if the 'propertyName' is available inside 'jo', and that property uses the appropriate Json-Type - JsonNumber. Furthermore, that JsonNumber must be assignable to Java Primitive Type double, or this method will throw an exception.
        Throws:
        JsonPropMissingException - This exception throws if the JsonObject (parameter 'jo') does not have any properties with the name 'propertyName'.
        JsonArithmeticObjException - Java's implementation of BigDecimal.doubleValue() will return an infinity constant (Double.NEGATIVE_INFINITY or Double.POSITIVE_INFINITY) when the magnitude of the returned value is too large to fit inside the Java Type double.

        This method checks for the infinity constants, and then proceeds to throw this exception when they are detected.
        JsonTypeObjException - If the property (specified by 'propertyName') is extracted, but that property does not actually contain a JsonNumber (but rather, some other non-null Json-Type), then this exception throws.
        JsonNullPrimitiveObjException - If 'propertyName' specifies a property inside 'jo' that has been assigned Json-Null, then this exception will throw. (Unlike Json, in Java a Primitive double will not accept 'null' as a value).
        See Also:
        RJInternal.GET(JsonObject, String, Class, Function), RJInternal.DOUBLE_WITH_CHECK(JsonNumber)
        Code:
        Exact Method Body:
         return GET(jo, propertyName, double.class, RJInternal::DOUBLE_WITH_CHECK);
        
      • getFloat

        🡅  🡇     🗕  🗗  🗖
        public static float getFloat​(JsonArray ja,
                                     int index)
        Retrieve a JsonArray element, and transform it to a 'float' primitive

        NOTE: If the precision of the provided JsonNumber contains too much information, the extra digits will simply be lost; no exceptions will throw; and the method shall return a rounded answer - gracefully.

        If the magnitude of the number is too large or too small, an ArithmeticException will throw, as explained below.
        Parameters:
        ja - Any instance of JsonArray
        index - A valid index into array parameter 'ja'. In Json (and unlike Java), array element types are not actually checked for consistency - meaning an array may hold many different types! This array-index must contain a JsonNumber
        Returns:
        An instance of Java-Type float, if and only if the array element located at 'index' uses the appropriate Json-Type - JsonNumber, and that element may be properly mapped to a Java float.
        Throws:
        java.lang.IndexOutOfBoundsException - If 'index' is out of the bounds of 'ja'
        JsonTypeArrException - If the array-element (specified by 'index') does not actually contain a JsonNumber (but rather, some other non-null Json-Type), then this exception throws.
        JsonArithmeticArrException - Java's implementation of BigDecimal.floatValue() will return an infinity constant (Float.NEGATIVE_INFINITY or Float.POSITIVE_INFINITY) when the magnitude of the returned value is too large to fit inside the Java Type float.

        This method checks for the infinity constants, and then proceeds to throw this exception when they are detected.
        JsonNullPrimitiveArrException - If 'index' specifies an element inside 'ja' that has been assigned Json-Null, then this exception will throw. (Unlike Json, in Java a Primitive float will not accept 'null' as a value).
        See Also:
        RJInternal.GET(JsonArray, int, Class, Function), RJInternal.FLOAT_WITH_CHECK(JsonNumber)
        Code:
        Exact Method Body:
         return GET(ja, index, float.class, RJInternal::FLOAT_WITH_CHECK);
        
      • getFloat

        🡅  🡇     🗕  🗗  🗖
        public static float getFloat​(JsonObject jo,
                                     java.lang.String propertyName)
        Extract a JsonObject property, and transform it to a 'float' primitive

        NOTE: If the precision of the provided JsonNumber contains too much information, the extra digits will simply be lost; no exceptions will throw; and the method shall return a rounded answer - gracefully.

        If the magnitude of the number is too large or too small, an ArithmeticException will throw, as explained below.
        Parameters:
        jo - Any instance of JsonObject
        propertyName - The name of the JSON property that should be contained within 'jo'. This property will be retrieved and subsequently transformed / converted to Java-Type float.
        Returns:
        An instance of Java-Type float, if and only if the 'propertyName' is available inside 'jo', and that property uses the appropriate Json-Type - JsonNumber. Furthermore, that JsonNumber must be assignable to Java Primitive Type float, or this method will throw an exception.
        Throws:
        JsonPropMissingException - This exception throws if the JsonObject (parameter 'jo') does not have any properties with the name 'propertyName'.
        JsonArithmeticObjException - Java's implementation of BigDecimal.floatValue() will return an infinity constant (Float.NEGATIVE_INFINITY or Float.POSITIVE_INFINITY) when the magnitude of the returned value is too large to fit inside the Java Type float.

        This method checks for the infinity constants, and then proceeds to throw this exception when they are detected.
        JsonTypeObjException - If the property (specified by 'propertyName') is extracted, but that property does not actually contain a JsonNumber (but rather, some other non-null Json-Type), then this exception throws.
        JsonNullPrimitiveObjException - If 'propertyName' specifies a property inside 'jo' that has been assigned Json-Null, then this exception will throw. (Unlike Json, in Java a Primitive float will not accept 'null' as a value).
        See Also:
        RJInternal.GET(JsonObject, String, Class, Function), RJInternal.FLOAT_WITH_CHECK(JsonNumber)
        Code:
        Exact Method Body:
         return GET(jo, propertyName, float.class, RJInternal::FLOAT_WITH_CHECK);
        
      • getBoolean

        🡅  🡇     🗕  🗗  🗖
        public static boolean getBoolean​(JsonArray ja,
                                         int index)
        Retrieve a JsonArray element, and transform it to a 'boolean' primitive
        Parameters:
        ja - Any instance of JsonArray
        index - A valid index into array parameter 'ja'. In Json (and unlike Java), array element types are not actually checked for consistency - meaning an array may hold many different types! This array-index must contain a JSON-BOOLEAN
        Returns:
        An instance of Java-Type boolean, if and only if the array element located at 'index' uses the appropriate Json-Type - JSON-BOOLEAN, and that element may be properly mapped to a Java boolean.
        Throws:
        java.lang.IndexOutOfBoundsException - If 'index' is out of the bounds of 'ja'
        JsonTypeArrException - If the array-element (specified by 'index') does not actually contain a JSON-BOOLEAN (but rather, some other non-null Json-Type), then this exception throws.
        JsonNullPrimitiveArrException - If 'index' specifies an element inside 'ja' that has been assigned Json-Null, then this exception will throw. (Unlike Json, in Java a Primitive boolean will not accept 'null' as a value).
        See Also:
        ReadBoxedJSON.getBoolean(JsonArray, int)
        Code:
        Exact Method Body:
         // This method (defined below) allows for null-returns, but "getBoolean" does not.  
         // "getBOOLEAN" will only return null if the actual array location 'index' actually has
         // the word 'null' listed.
        
         Boolean ret = ReadBoxedJSON.getBoolean(ja, index);
        
         // In that case, throw the Null-Primitive Exception
         if (ret == null) throw new JsonNullPrimitiveArrException
                 (ja, index, TRUE, boolean.class);
        
         return ret;
        
      • getBoolean

        🡅     🗕  🗗  🗖
        public static boolean getBoolean​(JsonObject jo,
                                         java.lang.String propertyName)
        Extract a JsonObject property, and transform it to a 'boolean' primitive
        Parameters:
        jo - Any instance of JsonObject
        propertyName - The name of the JSON property that should be contained within 'jo'. This property will be retrieved and subsequently transformed / converted to Java-Type boolean.
        Returns:
        An instance of Java-Type boolean, if and only if the 'propertyName' is available inside 'jo', and that property uses the appropriate Json-Type - JSON-BOOLEAN. Furthermore, that JSON-BOOLEAN must be assignable to Java Primitive Type boolean, or this method will throw an exception.
        Throws:
        JsonPropMissingException - This exception throws if the JsonObject (parameter 'jo') does not have any properties with the name 'propertyName'.
        JsonTypeObjException - If the property (specified by 'propertyName') is extracted, but that property does not actually contain a JSON-BOOLEAN (but rather, some other non-null Json-Type), then this exception throws.
        JsonNullPrimitiveObjException - If 'propertyName' specifies a property inside 'jo' that has been assigned Json-Null, then this exception will throw. (Unlike Json, in Java a Primitive boolean will not accept 'null' as a value).
        See Also:
        ReadBoxedJSON.getBoolean(JsonObject, String, boolean)
        Code:
        Exact Method Body:
         // Since 'false' is passed, a null return-value will mean that the property was actually
         // set to null in the JsonObject itself.  (It *IS NOT* missing, it is present, but rather
         // declared null)
        
         Boolean ret = ReadBoxedJSON.getBoolean(jo, propertyName, false);
        
         if (ret == null) throw new JsonNullPrimitiveObjException
             (jo, propertyName, TRUE, boolean.class);
        
         // NOTE: Java's Type-Stuff can automatically convert Boolean -> boolean
         else return ret;