Package Torello.JSON

Class RorPPrimJSON


  • public class RorPPrimJSON
    extends java.lang.Object
    Utilities for parsing & converting JsonString's or JsonNumber's 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 (either a number or a string) from a JsonArray or JsonObject and converts it into a corresponding Java primitive type.

    This class exists to make reading numeric and boolean values from large, complex JSON structures both safer and easier. While JSON itself is loosely typed, Java is not, and bridging that gap reliably requires careful handling of value types, missing fields, and unexpected representations.
    In practice, JSON sources may freely alternate between numeric values and their string representations (for example 3 versus "3"), may omit optional fields entirely, or may return null in cases where a value is not mandatory. This class provides explicit, well-organized methods for handling each of these cases, ensuring that conversions are performed deliberately and that mistakes are detected immediately.

    Rather than attempting to infer or generate higher-level Java types, this class focuses on making low-level JSON access predictable and transparent. A significant amount of effort is dedicated to validating inputs and producing detailed error messages, so that when something goes wrong while traversing an unfamiliar or evolving JSON document, the cause of the failure is clear and actionable. The result is less repeated boilerplate, fewer silent failures, and greater confidence when consuming complex JSON data.



    Method Parameters

    Parameter Explanation
    ja The source JsonArray from which the value is retrieved.
    index The zero-based index within ja identifying the target element.
    jo The source JsonObject from which the property value is retrieved.
    propertyName The name of the property whose value is to be read and parsed.
    optionalUserParser An optional user-supplied parser applied to the raw string value before conversion; may be null to use default parsing behavior.


    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
    • 14 Method(s), 14 declared static
    • 0 Field(s)