java.lang.Object
com.darkcollective.relix.json.JsonReader

public final class JsonReader extends Object
A minimal, dependency-free JSON parser producing plain Java objects — the reading counterpart to JsonWriter, for callers that want a document back rather than a typed domain object.

Despite the name it is not an incremental, pull-style reader over a stream: parse(java.lang.String) takes the whole document as text and hands back the whole tree. The name pairs with JsonWriter because reading and writing are this module's two directions, not because the two mirror each other call for call.

Its callers are the catalog manifests: the connector-plugin one the engine reads, and the JDBC driver one a connector provider keeps (DriverCatalog, in relix-connectors-std). Both want a small, controlled document as maps and lists, which is why this produces those rather than the relix Value tree that JsonValues builds for data arriving from a source.

It lives here, beside JsonStrings, because escaping is the half of the JSON grammar most easily gotten subtly wrong, and a parser that unescapes in a different module from the writer that escapes is a contract nothing checks.

Parses the standard JSON value grammar into plain Java objects:

  • object → LinkedHashMap<String,Object> (insertion order)
  • array → List<Object>
  • string → String (with the standard JSON backslash and 4-hex-digit escapes)
  • number → String (kept verbatim — the catalog needs no arithmetic)
  • true/false → Boolean; null → null

Malformed input raises IllegalArgumentException. Used by both the driver and connector catalogs.

  • Method Details

    • parse

      public static Object parse(String json)
      Parses a single JSON document.
      Parameters:
      json - the JSON text
      Returns:
      the parsed value (Map / List / String / Boolean / null)
      Throws:
      IllegalArgumentException - if the text is not well-formed JSON