com.github.bingoohuang.utils.codec.Json Maven / Gradle / Ivy
package com.github.bingoohuang.utils.codec;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.github.bingoohuang.utils.lang.Mapp;
import java.util.List;
import java.util.Map;
public class Json {
public static String jsonWithType(Object obj) {
return JSON.toJSONString(obj, SerializerFeature.WriteClassName);
}
@SuppressWarnings("unchecked")
public static T unJsonWithType(String json) {
return (T) JSON.parse(json);
}
public static String json(Object obj) {
return JSON.toJSONString(obj);
}
public static String jsonOf(Object... keyAndValues) {
return JSON.toJSONString(Mapp.map(keyAndValues));
}
public static Map unJson(String json) {
return JSON.parseObject(json);
}
public static T unJson(String json, Class clazz) {
return JSON.parseObject(json, clazz);
}
public static List unJsonArray(String json) {
return JSON.parseArray(json);
}
public static List unJsonArray(String json, Class clazz) {
return JSON.parseArray(json, clazz);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy