Package tech.mgl.core.utils
Class MGL_JsonUtils
java.lang.Object
tech.mgl.core.utils.MGL_JsonUtils
- Author:
- www.mgl.tech
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.alibaba.fastjson2.JSONObject5static com.alibaba.fastjson2.JSONObjectfrom(MGL_JSONConfig jconfig, Object... objs) static Stringobj2JSONString(Object... objs) static Stringobj2JSONString(MGL_JSONConfig config, Object... objs) 返回jsonString类型static Stringresult(boolean status) static Stringstatic Stringstatic Stringresult(boolean status, Integer p_status, String info, Object content, MGL_JSONConfig config) 获取json格式字符串static Stringstatic Stringstatic Stringresult(boolean status, String info, Object obj, MGL_JSONConfig config) static <T> Tstatic <T> TtoCaseObject(String json, Class<T> clazz, com.alibaba.fastjson2.PropertyNamingStrategy cases) 将下划线转换为驼峰的形式,例如:user_name-->userName 好像多余的 不管 设置不设置 转Java对象的时候 都会把user_name改成userNamestatic Object按指定的规则把对象转换JSON 查看PropertyNamingStrategystatic ObjecttoJson(Object obj, com.alibaba.fastjson2.PropertyNamingStrategy cases, MGL_JSONConfig config) Deprecated.static ObjecttoJson(Object obj, MGL_JSONConfig config) 按指定的规则把对象转换JSON 查看PropertyNamingStrategy基于注解 把Java对象转map
-
Constructor Details
-
MGL_JsonUtils
public MGL_JsonUtils()
-
-
Method Details
-
from
-
from
5 -
obj2JSONString
返回jsonString类型- Parameters:
config- 配置,有大对象时,把objs- 转换的对象- Returns:
-
obj2JSONString
-
result
public static String result(boolean status, Integer p_status, String info, Object content, MGL_JSONConfig config) 获取json格式字符串- Parameters:
p_status- 成功或失败标志,true falseinfo- 描述信息content- 更多内容,格式为任何键值对(key = value)集合或者bean- Returns:
-
result
- Parameters:
status-info-- Returns:
- 参数 String 返回类型 最后放return 不然格式化会乱套
-
result
- Parameters:
status-info-obj-- Returns:
-
result
-
result
- Parameters:
status-p_status-- Returns:
-
result
- Parameters:
status-- Returns:
-
result
- Parameters:
status-p_status-info-- Returns:
- 参数 String 返回类型 最后放return 不然格式化会乱套
-
toBean
- Parameters:
from-toCls-- Returns:
- Throws:
Exception- 参数 T 返回类型 最后放return 不然格式化会乱套
-
toCaseObject
public static <T> T toCaseObject(String json, Class<T> clazz, com.alibaba.fastjson2.PropertyNamingStrategy cases) 将下划线转换为驼峰的形式,例如:user_name-->userName 好像多余的 不管 设置不设置 转Java对象的时候 都会把user_name改成userName- Type Parameters:
T-- Parameters:
json-clazz-- Returns:
- Throws:
IOException
-
toJson
@Deprecated public static Object toJson(Object obj, com.alibaba.fastjson2.PropertyNamingStrategy cases, MGL_JSONConfig config) throws Exception Deprecated.过度之用 已弃用- Parameters:
obj-cases-config-- Returns:
- Throws:
Exception
-
toJson
按指定的规则把对象转换JSON 查看PropertyNamingStrategy- Parameters:
obj-- Returns:
- Throws:
Exception
-
toJson
public static Object toJson(Object obj, com.alibaba.fastjson2.PropertyNamingStrategy cases) throws Exception 按指定的规则把对象转换JSON 查看PropertyNamingStrategy- Parameters:
obj-cases-- Returns:
- Throws:
Exception
-
toMapWithAnnotation
基于注解 把Java对象转map- Parameters:
t-- Returns:
- Throws:
Exception
-