クラス JSONParser

java.lang.Object
io.github.takenoko4096.json.JSONParser

@NullMarked public class JSONParser extends Object
json文字列を解釈してjson構造に変換するクラス。
  • コンストラクタの概要

    コンストラクタ
    コンストラクタ
    説明
    新しくパーサーを作成します。
  • メソッドの概要

    修飾子とタイプ
    メソッド
    説明
    static JSONArray
    array(String text)
    引数に渡された文字列をjson配列としてパースします。
    static JSONObject
    object(String text)
    引数に渡された文字列をjsonオブジェクトとしてパースします。
    <T extends JSONValue<?>>
    T
    parse(String text, Class<T> clazz)
    引数に渡された文字列をjsonとしてパースします。
    引数に渡された文字列をjson構造としてパースします。

    クラスから継承されたメソッド Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • コンストラクタの詳細

    • JSONParser

      public JSONParser()
      新しくパーサーを作成します。
  • メソッドの詳細

    • parse

      public <T extends JSONValue<?>> T parse(String text, Class<T> clazz) throws JSONParseException
      引数に渡された文字列をjsonとしてパースします。
      型パラメータ:
      T - 戻り値の型。
      パラメータ:
      text - json。
      clazz - クラス。
      戻り値:
      パースで得られたjsonの値。
      例外:
      JSONParseException - jsonが無効な場合。
    • object

      public static JSONObject object(String text) throws JSONParseException
      引数に渡された文字列をjsonオブジェクトとしてパースします。
      パラメータ:
      text - json
      戻り値:
      jsonオブジェクト
      例外:
      JSONParseException - jsonが無効な場合。
    • array

      public static JSONArray array(String text) throws JSONParseException
      引数に渡された文字列をjson配列としてパースします。
      パラメータ:
      text - json
      戻り値:
      json配列
      例外:
      JSONParseException - jsonが無効な場合。
    • structure

      public static JSONStructure structure(String text) throws JSONParseException
      引数に渡された文字列をjson構造としてパースします。
      パラメータ:
      text - json
      戻り値:
      json構造
      例外:
      JSONParseException - jsonが無効な場合。