public class JsonUtils extends Converter
限定符和类型 | 方法和说明 |
---|---|
static String |
formatJson(String json) |
static JSONObject |
formatJSONObject(String json) |
static boolean |
getBoolean(JSONObject obj,
String key,
boolean defaultValue) |
static double |
getDouble(JSONObject obj,
String key,
double defaultValue) |
static float |
getFloat(JSONObject obj,
String key,
float defaultValue) |
static int |
getInt(JSONObject obj,
String key,
int defaultValue) |
static JSONArray |
getJSONArray(JSONObject obj,
String key) |
static JSONObject |
getJSONObject(JSONObject obj,
String key) |
static long |
getLong(JSONObject obj,
String key,
long defaultValue) |
static Object |
getObject(JSONObject obj,
String key) |
static JSONObject |
getObject(String json) |
static String |
getString(JSONObject obj,
String key) |
static String |
getString(JSONObject obj,
String key,
String defaultValue) |
static ParameterizedType |
getType(Class raw,
Type... args) |
static <T> List<T> |
parserToList(Class<T> c,
JSONArray jsonArray,
boolean useAnnotation) |
static <T> List<T> |
parserToList(Class<T> c,
JSONArray jsonArray,
boolean useAnnotation,
boolean excludeTransient) |
static <T> List<T> |
parserToList(Class<T> c,
String str,
boolean useAnnotation)
解析JSONArray格式字符串到 List
|
static <T> List<T> |
parserToList(Class<T> c,
String str,
boolean useAnnotation,
boolean excludeTransient) |
static <T> T |
parserToObject(Class<T> c,
JSONObject jsonObject,
boolean useAnnotation) |
static <T> T |
parserToObject(Class<T> c,
JSONObject jsonObject,
boolean useAnnotation,
boolean excludeTransient) |
static <T> T |
parserToObject(Class<T> c,
String str,
boolean useAnnotation)
解析JSONObject格式字符串到 Object
|
static <T> T |
parserToObject(Class<T> c,
String str,
boolean useAnnotation,
boolean excludeTransient) |
static <T> T |
parserToObjectByUrl(Class<T> c,
String urlStr) |
static <T> JSONArray |
toJSONArray(List<T> obj,
boolean useAnnotation)
转换Object到JSONArray
|
static <T> JSONObject |
toJSONObject(T obj,
boolean useAnnotation)
转换Object到JSONObject
|
static <T> JSONObject |
toJSONObject(T obj,
boolean useAnnotation,
boolean excludeTransient) |
getFieldName, isBaseClass, isTransient, isWrapClass, parseBoolean, parseDouble, parseFloat, parseInt, parseLong, parserJson, parserJsonList, parserXml, parserXmlList
public static <T> JSONArray toJSONArray(List<T> obj, boolean useAnnotation)
T
- obj
- public static <T> JSONObject toJSONObject(T obj, boolean useAnnotation)
T
- obj
- public static <T> JSONObject toJSONObject(T obj, boolean useAnnotation, boolean excludeTransient)
public static <T> T parserToObject(Class<T> c, String str, boolean useAnnotation) throws JSONParserException
T
- c
- str
- useAnnotation
- JSONParserException
public static <T> T parserToObject(Class<T> c, String str, boolean useAnnotation, boolean excludeTransient) throws JSONParserException
public static <T> List<T> parserToList(Class<T> c, String str, boolean useAnnotation) throws JSONParserException
T
- c
- str
- useAnnotation
- JSONParserException
public static <T> List<T> parserToList(Class<T> c, String str, boolean useAnnotation, boolean excludeTransient) throws JSONParserException
public static <T> T parserToObjectByUrl(Class<T> c, String urlStr) throws JSONParserException
T
- c
- urlStr
- JSONParserException
public static <T> T parserToObject(Class<T> c, JSONObject jsonObject, boolean useAnnotation) throws JSONParserException
public static <T> T parserToObject(Class<T> c, JSONObject jsonObject, boolean useAnnotation, boolean excludeTransient) throws JSONParserException
public static <T> List<T> parserToList(Class<T> c, JSONArray jsonArray, boolean useAnnotation) throws JSONParserException
public static <T> List<T> parserToList(Class<T> c, JSONArray jsonArray, boolean useAnnotation, boolean excludeTransient) throws JSONParserException
public static ParameterizedType getType(Class raw, Type... args)
public static JSONObject formatJSONObject(String json) throws JSONException
JSONException
public static int getInt(JSONObject obj, String key, int defaultValue)
public static long getLong(JSONObject obj, String key, long defaultValue)
public static boolean getBoolean(JSONObject obj, String key, boolean defaultValue)
public static float getFloat(JSONObject obj, String key, float defaultValue)
public static double getDouble(JSONObject obj, String key, double defaultValue)
public static JSONObject getObject(String json)
public static JSONObject getJSONObject(JSONObject obj, String key)
public static JSONArray getJSONArray(JSONObject obj, String key)