Initialize local project and fix ranch growth synchronization
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
package com.diyidan.game.util;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.diyidan.game.network.model.JsonData;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/* JADX INFO: loaded from: C:\Users\11789\Documents\Projects\Codex_ws\myrzx_fang\analysis\base_classes.dex */
|
||||
public class JsonUtils {
|
||||
public static <T> JsonData<T> parseNetworkResponse(String str, TypeReference<JsonData<T>> typeReference) {
|
||||
return (JsonData) JSON.parseObject(str, typeReference, new Feature[0]);
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
@Deprecated
|
||||
public static <T> JsonData<T> parseNetworkResponse(String str, Class<? extends T> cls) {
|
||||
JsonData<T> jsonData = (JsonData<T>) ((JsonData) JSON.parseObject(str, new TypeReference<JsonData<T>>() { // from class: com.diyidan.game.util.JsonUtils.1
|
||||
}, new Feature[0]));
|
||||
jsonData.setData(JSON.parseObject(JSON.toJSONString(jsonData.getData()), cls));
|
||||
return jsonData;
|
||||
}
|
||||
|
||||
public static <T> T parseJson(String str, Class<? extends T> cls) {
|
||||
return (T) JSON.parseObject(str, cls);
|
||||
}
|
||||
|
||||
public static <T> T parseJson(String str, Type type) {
|
||||
return (T) JSON.parseObject(str, type, new Feature[0]);
|
||||
}
|
||||
|
||||
public static <T> List<T> parseListJson(String str, Class<T> cls) {
|
||||
return JSON.parseArray(str, cls);
|
||||
}
|
||||
|
||||
public static <T> Map<String, T> parseMapJson(String str) {
|
||||
try {
|
||||
return (Map) JSON.parseObject(str, new TypeReference<Map<String, T>>() { // from class: com.diyidan.game.util.JsonUtils.2
|
||||
}, new Feature[0]);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> List<Map<String, T>> parseListMapJson(String str, Class<T> cls) {
|
||||
try {
|
||||
return (List) JSON.parseObject(str, new TypeReference<List<Map<String, T>>>() { // from class: com.diyidan.game.util.JsonUtils.3
|
||||
}, new Feature[0]);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String convert2Json(Object obj) {
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
return JSON.toJSONString(obj, SerializerFeature.DisableCircularReferenceDetect);
|
||||
}
|
||||
|
||||
public static String convert2ListJson(List list) {
|
||||
StringBuilder sb = new StringBuilder("[");
|
||||
for (Object obj : list) {
|
||||
if (obj != null) {
|
||||
sb.append(JSON.toJSONString(obj, SerializerFeature.DisableCircularReferenceDetect));
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
if (sb.length() > 1) {
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
}
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user