Package top.focess.qq.api.util.json
Class JSON
- java.lang.Object
-
- top.focess.qq.api.util.json.JSONObject
-
- top.focess.qq.api.util.json.JSON
-
- All Implemented Interfaces:
Serializable,SectionMap
- Direct Known Subclasses:
JSONSection
public class JSON extends JSONObject implements SectionMap
This class is used to define a JSON object as Map.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsSection(String key)Indicate there is a section named keyJSONSectioncreateSection(String key)Create the section named key Note: if the section named key already exists, it will be replaced by a new section<T> Tget(String key)Get the value of the key-value pairJSONListgetList(String key)Get the list named keyJSONSectiongetSection(String key)Get the section named key Note: if the section named key does not exist, it will be createdMap<String,Object>getValues()Get all the key-value pairsStringtoJson()Translate this JSON instance into json StringStringtoString()-
Methods inherited from class top.focess.qq.api.util.json.JSONObject
get, getJSON, getList, parse
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface top.focess.qq.api.util.SectionMap
compute, contains, getOrDefault, keys, remove, set
-
-
-
-
Method Detail
-
createSection
public JSONSection createSection(String key)
Description copied from interface:SectionMapCreate the section named key Note: if the section named key already exists, it will be replaced by a new section- Specified by:
createSectionin interfaceSectionMap- Parameters:
key- the key of the Section- Returns:
- a section named key
-
getValues
public Map<String,Object> getValues()
Description copied from interface:SectionMapGet all the key-value pairs- Specified by:
getValuesin interfaceSectionMap- Returns:
- all the key-value pairs
-
getSection
public JSONSection getSection(String key)
Description copied from interface:SectionMapGet the section named key Note: if the section named key does not exist, it will be created- Specified by:
getSectionin interfaceSectionMap- Parameters:
key- the key of the Section- Returns:
- the section named key
-
containsSection
public boolean containsSection(String key)
Description copied from interface:SectionMapIndicate there is a section named key- Specified by:
containsSectionin interfaceSectionMap- Parameters:
key- the key of the Section- Returns:
- true there is a section named key, false otherwise
-
getList
public JSONList getList(String key)
Description copied from class:JSONObjectGet the list named keyNote: this is for JSON only.
- Overrides:
getListin classJSONObject- Parameters:
key- the key of the list- Returns:
- a list named key
-
toJson
public String toJson()
Description copied from class:JSONObjectTranslate this JSON instance into json String- Specified by:
toJsonin classJSONObject- Returns:
- json String translated from this JSON instance
-
get
public <T> T get(String key)
Description copied from class:JSONObjectGet the value of the key-value pairNote: this is for JSON only.
- Specified by:
getin interfaceSectionMap- Overrides:
getin classJSONObject- Type Parameters:
T- the type of the value- Parameters:
key- the key- Returns:
- the value
-
-