Package top.focess.qq.api.util.json
Class JSONObject
- java.lang.Object
-
- top.focess.qq.api.util.json.JSONObject
-
-
Constructor Summary
Constructors Constructor Description JSONObject()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <T> Tget(int index)Get the value at the given index<T> Tget(String key)Get the value of the key-value pairJSONObjectgetJSON(int index)Get as JSON at the given indexJSONObjectgetList(int index)Get the list at the given indexJSONObjectgetList(String key)Get the list named keystatic JSONObjectparse(String json)Parse the given string into a JSON object.abstract StringtoJson()Translate this JSON instance into json String
-
-
-
Method Detail
-
parse
@NotNull @Contract("_ -> new") public static JSONObject parse(String json)Parse the given string into a JSON object.- Parameters:
json- the string to parse- Returns:
- the JSON object
-
get
public <T> T get(int index)
Get the value at the given indexNote: this is for JSONList only.
- Type Parameters:
T- the type of the value- Parameters:
index- the index of the value- Returns:
- the value at the given index
-
get
public <T> T get(String key)
Get the value of the key-value pairNote: this is for JSON only.
- Type Parameters:
T- the type of the value- Parameters:
key- the key- Returns:
- the value
-
getList
public JSONObject getList(int index)
Get the list at the given indexNote: this is for JSONList only.
- Parameters:
index- the index of the list- Returns:
- the list at the given index
-
getList
public JSONObject getList(String key)
Get the list named keyNote: this is for JSON only.
- Parameters:
key- the key of the list- Returns:
- a list named key
-
getJSON
public JSONObject getJSON(int index)
Get as JSON at the given indexNote: this is for JSONList only.
- Parameters:
index- the index of the JSON- Returns:
- the JSON at the given index
-
toJson
public abstract String toJson()
Translate this JSON instance into json String- Returns:
- json String translated from this JSON instance
-
-