jimu-decompiled/sources/com/ubt/jimu/utils/JsonHelper.java
2025-05-13 19:24:51 +02:00

49 lines
1.3 KiB
Java

package com.ubt.jimu.utils;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.lang.reflect.Type;
/* loaded from: classes2.dex */
public class JsonHelper {
private static final Gson a = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
public static Object a(String str, Type type) {
if (str != null) {
try {
return a.fromJson(str, type);
} catch (Exception e) {
Log.e("GSON", e.getMessage() + "");
}
}
return null;
}
public static <T> T b(String str, Class<T> cls) {
if (!android.text.TextUtils.isEmpty(str)) {
try {
return (T) a.fromJson(str, (Class) cls);
} catch (Exception e) {
Log.e("GSON", e.getMessage() + "");
}
}
return null;
}
public static Object a(String str, Class<?> cls) {
if (str != null) {
try {
return a.fromJson(str, (Class) cls);
} catch (Exception e) {
Log.e("GSON", e.getMessage() + "");
}
}
return null;
}
public static String a(Object obj) {
return a.toJson(obj);
}
}