1、JSONObject:json對象
屬性:Map<String, Object> map,鍵值對實際存在該map中
方法:
實際用map的方法實現的有:size,isEmpty,containsKey,containsValue,get,put,clear,remove,keySet,entrySet
toString、toJSONString:json對象轉為json串
toJavaObject:json對象轉為java對象
getJSONObject:獲取JSONObject對象
getJSONArray:獲取JSONArray對象
getString:獲取String對象
getInteger:獲取int值
getLong:獲取long值
getDouble:獲取double值
等等
2、JSONArray:json數組
屬性:List<Object> list,對象實際存在該list中
方法:
實際用list的方法實現的有:size,isEmpty,contains,iterator,add,remove,addAll,removeAll,clear,get
toString、toJSONString:json數組轉為json串
getJSONObject:獲取JSONObject對象
getJSONArray:獲取JSONArray對象
getString:獲取String對象
getInteger:獲取int值
getLong:獲取long值
getDouble:獲取double值
3、JSON:json操作
Object parse(String text):解析json串,得到Object對象
JSONObject parseObject(String text) :解析json串,得到JSONObject對象
T parseObject(String text, Classclazz):解析json串,得到指定類的對象
JSONArray parseArray(String text):解析json串,得到JSONArray對象
List ?parseArray(String text, Classclazz):解析json串,得到指定類的對象列表
String toJSONString(Object object):Object轉String
Object toJSON(Object javaObject):java對象轉為json對象
T toJavaObject(JSON json, Classclazz):json對象轉為java對象