public class JsonHelper extends Object
| 构造器和说明 |
|---|
JsonHelper() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
format(String json)
格式化 JSON,使其美观输出到控制或其他地方 请注意 对于json中原有\n \t 的情况未做过多考虑 得到格式化json数据 退格用\t 换行用\r
|
static String |
javaValue2jsonValue(String str)
转义注释和缩进
|
static Object |
json2Map(String jsonStr)
这是一个更加的 json 解析方法 就算是{'a:a{dsa}':"{fdasf[dd]}"} 这样的也可以处理
当然{a:{b:{c:{d:{e:[1,2,3,4,5,6]}}}}}更可以处理
|
static <T> String |
jsonArr(T[] o,
java.util.function.Function<T,String> fn)
输入任意类型数组,在 fn 作适当的转换,返回 JSON 字符串
|
static String |
jsonString_covernt(String str)
输出到 JSON 文本时候的换行
|
static Object |
parse(String str)
解析 JSON 为 Map 或 List
|
static List<Map<String,Object>> |
parseList(String str)
解析 JSON 字符串为 List
|
static Map<String,Object> |
parseMap(String str)
解析 JSON 字符串为 Map
|
static <T> T |
parseMapAsBean(String json,
Class<T> clz)
解析 JSON 字符串转换为 Bean 对象
|
static String |
removeComemnt(String str)
删除 JSON 注释
|
static String |
toJson(Object obj)
对 Object 尝试类型检测,将其合适地转换为 JSON 字符串返回。
|
public static Map<String,Object> parseMap(String str)
str - JSON 字符串public static <T> T parseMapAsBean(String json, Class<T> clz)
json - JSON 字符串clz - Bean 对象类引用public static List<Map<String,Object>> parseList(String str)
str - 字符串public static String toJson(Object obj)
obj - 任意对象public static <T> String jsonArr(T[] o, java.util.function.Function<T,String> fn)
o - 数组fn - 元素处理器,返回元素 JSON 字符串public static String format(String json)
json - 原 JSON 字符串public static String removeComemnt(String str)
str - 待处理的字符串public static String jsonString_covernt(String str)
str - JSON 字符串public static String javaValue2jsonValue(String str)
str - JSON 字符串Copyright © 2013–2021 AJAXJS. All rights reserved.