/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  net.sf.json.JSONArray
 *  net.sf.json.JSONObject
 */
package com.hst.common.util;

import com.hst.framework.util.HstToolsUtil;
import com.hst.taxService.domain.gt3.HxzgDjCxNsrdjxxRequestDomain;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class HstJsonUtil {
    private static String BEAN_TO_JSON = "result";
    private static String LIST_TO_JSON = "dataList";

    public static <T> T jsonToBean(String json, Class<T> clazz) {
        Object t = null;
        if (HstToolsUtil.isNullOrEmpty(json)) {
            return (T)t;
        }
        try {
            JSONObject jsonObject = JSONObject.fromObject((Object)json);
            t = JSONObject.toBean((JSONObject)jsonObject, clazz);
        }
        catch (Exception e) {
            e.printStackTrace();
            t = null;
        }
        return (T)t;
    }

    public static <T> T jsonToBeanToList(String json, Class<T> clazz, Map<String, Class> classMap) {
        Object t = null;
        if (HstToolsUtil.isNullOrEmpty(json)) {
            return (T)t;
        }
        try {
            JSONObject jsonObject = JSONObject.fromObject((Object)json);
            t = JSONObject.toBean((JSONObject)jsonObject, clazz, classMap);
        }
        catch (Exception exception) {
            t = null;
        }
        return (T)t;
    }

    public static String beanToJson(Object bean) {
        String json = "";
        String modify = BEAN_TO_JSON;
        try {
            JSONObject jsonObject = new JSONObject();
            jsonObject.accumulate(modify, bean);
            json = jsonObject.toString();
        }
        catch (Exception exception) {
            json = "";
        }
        return json;
    }

    public static String beanToJson(String modify, Object bean) {
        String json = "";
        if (HstToolsUtil.isNullOrEmpty(modify)) {
            modify = "BEAN_TO_JSON";
        }
        try {
            JSONObject jsonObject = new JSONObject();
            jsonObject.accumulate(modify, bean);
            json = jsonObject.toString();
        }
        catch (Exception exception) {
            json = "";
        }
        return json;
    }

    public static String beanCtreatJson(Object bean) {
        String json = "";
        try {
            JSONObject jsonObject = JSONObject.fromObject((Object)bean);
            json = jsonObject.toString();
        }
        catch (Exception exception) {
            json = "";
        }
        return json;
    }

    public static String listToJson(List list) {
        String json = "";
        String modify = LIST_TO_JSON;
        try {
            JSONObject jsonObject = new JSONObject();
            jsonObject.accumulate(modify, (Object)list);
            json = jsonObject.toString();
        }
        catch (Exception exception) {
            json = "";
        }
        return json;
    }

    public static String listToJson(String modify, List list) {
        String json = "";
        if (HstToolsUtil.isNullOrEmpty(modify)) {
            modify = "LIST_TO_JSON";
        }
        try {
            JSONObject jsonObject = new JSONObject();
            jsonObject.accumulate(modify, (Object)list);
            json = jsonObject.toString();
        }
        catch (Exception exception) {
            json = "";
        }
        return json;
    }

    public static String listCtreatJson(List list) {
        String json = "";
        try {
            JSONArray jsonObject = JSONArray.fromObject((Object)list);
            json = jsonObject.toString();
        }
        catch (Exception exception) {
            json = "";
        }
        return json;
    }

    public static <T> T jsonToRetrunBean(String json, Class<T> clazz) {
        Object t = null;
        if (HstToolsUtil.isNullOrEmpty(json)) {
            return (T)t;
        }
        try {
            JSONObject jsonObject = JSONObject.fromObject((Object)json);
            JSONObject retJson = JSONObject.fromObject((Object)jsonObject.getJSONObject("dsyyqh").get("retJson"));
            String resultJson = retJson.getString("result");
            t = JSONObject.toBean((JSONObject)JSONObject.fromObject((Object)resultJson), clazz);
        }
        catch (Exception e) {
            e.printStackTrace();
            t = null;
        }
        return (T)t;
    }

    public static void main(String[] args) {
        String json = "{\"uid\":null,\"bid\":null,\"sid\":null,\"ver\":null,\"kz\":null,\"nsrsbh\":null,\"djxh\":\"10113301000046726031\",\"DJXH\":\"10113301000046726031\",\"NSRSBH\":null}";
        HxzgDjCxNsrdjxxRequestDomain req = HstJsonUtil.jsonToBean(json, HxzgDjCxNsrdjxxRequestDomain.class);
        System.out.println(req.getDJXH());
    }
}
